I need to use seq()
to create the vector (2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2)
, but I'm stuck. I've done quite a bit of YouTube-ing and reading online, but can't find a specific enough solution.
Any help is appreciated, but please use the seq function when making recommendations.
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!