I have two column series - A series and B series.
df <- data.frame(A_1_1 = 'a',
A_2_1 = 'b',
A_3_1 = 'c',
B_0_1 = 'x',
B_0_2 = 'y',
B_0_3 = 'z'
)
I need to concatenate the A series with B series in the same sequence, to get the desired output.
Attempting something to this effect:
df %>% str_c(starts_with("A_"),"-",starts_with("B_"))
Thanks in advance!
This one did the job
df %>% {map2_dfc(select(.,starts_with("A_")),
select(.,starts_with("B_")),
function(x,y){
str_c(x,"-",y)
})} %>% View()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.