How can I combine columns of a data frame in the following fashion?
data <- data.frame(user.A = c(2,4,6),
user.B = c(11,13,15),
other.A = c(102,104,106),
other.B = c(201,103,105),
id = c('001', '004', '006'))
data
user.A user.B other.A other.B id
1 2 11 102 201 001
2 4 13 104 103 004
3 6 15 106 105 006
# Desired output.
user other id
1 2 102 001
2 11 201 001
3 4 104 004
4 13 103 004
5 6 106 006
6 15 105 006
I believe this can be done with dyplr
or tidyr
. The bind_rows
function in dplyr
does something similar but does not create this desired output.