Is there an R equivalent to Python's range function?
In Python I can do this:
for i in range(1, 4):
print(i)
1
2
3
and especially this:
for i in range(1, 0):
print(i)
# prints nothing!
Meanwhile in R:
> 1:0
[1] 1 0
also
> c(1:0)
[1] 1 0
and
> seq(from=1, to=0)
[1] 1 0
I need a function that given as input a min and a max returns a vector of increasing integers from min to max s.t. if max < min returns an empty vector.
This question on SO is different from mine. Talks about strings and seq()
which, as shown above, is not equivalent to range()
.