Generate sequence in R

Asked

Viewed 354 times

6

my logic is failing. But you could help me create a number array in R with this rule here?

Vetor=1,222,2,223,3,224,4,.......,221,442

Thank you very much.

2 answers

9


I would do so:

rep(1:221, each = 2) + c(0, 221)

6

Use the rbind() to interlink the sequences.

x = rep(1:221)
y = (x + 221)

Vetor = c(rbind(x, y))

head(Vetor)
#[1]   1 222   2 223   3 224

Browser other questions tagged

You are not signed in. Login or sign up in order to post.