powered by
Functions to generate increasing sequences
matlabColon(from, to)SeqInc(from, to)
SeqInc(from, to)
numeric. The start value
numeric. The end value.
A numeric vector, possibly empty.
matlabColon(a,b) returns a:b (R's version) unless a > b, in which case it returns integer(0). SeqInc(a,b) is similar, but results in error when the calculated length of the sequence (1+to-from) is negative.
seq
# NOT RUN { identical(3:5, matlabColon(3, 5)) ## => TRUE 3:1 ## => 3 2 1 matlabColon(3, 1) ## => integer(0) try(SeqInc(3, 1)) ## => Error SeqInc(3, 2) ## => integer(0) # }
Run the code above in your browser using DataLab