How can I combind two columns in the same data frame into one column, a simple example would be:
a <- data.frame(id = 1:3, v1 = c('a', NA, NA), v2 = c(NA, 'b', 'c'))
a
id v1 v2
1 a <NA>
2 <NA> b
3 <NA> c
And the output I need would be look like this:
a
id v1 v2 v3
1 a <NA> a
2 <NA> b b
3 <NA> c c
I found a similar post join matching columns in a data.frame or data.table, but I can not figure it out with my own case, please help, thanks
Hmm,
ifelse()maybe?