The function seq() can be used to create a sequence of numbers. For instance, seq(a,b) makes a vector of integers between a and b.
> x = seq(1, 10)
> x
[1] 1 2 3 4 5 6 7 8 9 10
There are many other options: for instance, seq(1, 15, length = 5)
makes a sequence of
5 numbers that are equally spaced between 1 and 15.
> x = seq(1, 15, length = 5)
> x
[1] 1.0 4.5 8.0 11.5 15.0
Using the by = 2
parameter, makes a sequences by jumps of 2 instead of the default 1.
> x = seq(0, 10, by = 2)
> x
[1] 0 2 4 6 8 10
Typing 3:11
is a shorthand for seq(3,11)
for integer arguments.
> x = 3:11
> x
[1] 3 4 5 6 7 8 9 10 11