R Multiple Element Sequence Matters

Asked 2 years ago, Updated 2 years ago, 34 views

x<-c(1:10)
y<-c (2:11)

x+y can be done, but x:y causes an error.

I want to create multiple columns, but only one is recognized.
I would appreciate it if you could let me know if you know any functions that can create such a sequence.
I'm sorry to bother you at such a busy time, but I appreciate your cooperation.

r

2022-09-30 10:47

1 Answers

Example of the map2 function in the purr package.

x<-c(1:3)
y<-c (2:4)

library(purrr)
map2 (.x=x, .y=y, .f=`:`)

[[1]]
[1] 1 2

[[2]]
[1] 2 3

[[3]]
[1] 3 4


2022-09-30 10:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.