+5 votes
in Programming Languages by (40.5k points)
I want to create a vector such that the difference between its elements is greater than 1.

E.g.

1,3,5,7,9,11

1 Answer

+1 vote
by (354k points)
selected by
 
Best answer

The seq() function can be used to create a vector with any step size in the sequence. The format of the seq() function is as follows:

seq(from, to, step_size)

Here is an example to create a vector with a difference between its elements 2.

> a=seq(1,11,2)
> a
[1]  1  3  5  7  9 11


...