(i) Differences in the first term of the R-equivalence sequence

Asked 2 years ago, Updated 2 years ago, 36 views

 for (i in (3:1))
{
    n = 1:10
    an<-i+(n-1)
}

With the above, you cannot create more than one sequence.
Please tell me how to make the first, second, and third sequences at once.
I look forward to your kind cooperation.

r

2022-09-30 18:50

1 Answers

library(purrrr)
map(1:3, `+`, 1:10)
[[1]]
 [1]  2  3  4  5  6  7  8  9 10 11

[[2]]
 [1]  3  4  5  6  7  8  9 10 11 12

[[3]]
 [1]  4  5  6  7  8  9 10 11 12 13


2022-09-30 18:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.