Using seq
function, you need to following two steps:
Step-1 Generate sequence from 2 to 10 using following code:
a<-seq(from=2,to = 10)
Step-2 Generate sequence from 10 to 2 using following code:
b<-seq(from=9,to = 2)
Now, combine above two results using following code:
data<-c(a,b)
The output should as follow:
> data
[1] 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2
Hope it works for you!
solved How to create the vector 2:10 and 10:2 using the seq function