Suppose I have something like this:
library(tidyr)
d=tribble(
~x1, ~x2, ~y,
"a", "one", 7,
"b", "one", 9,
"a", "two", 11
)
d
and I want to combine x1
and x2
to create a combo column, like this:
d %>% unite(combo,x1,x2)
Is there a way to take advantage of the fact that x1
and x2
are the only two character columns? I want to be able to say something like (this gives an error):
d %>% unite(combo, select_if(is.character))
Is there a way to do this that will work?