I have a data.frame
with two factor variables. Those two variables contain identical data except for when some values are missing. I want to end up with a data.frame
with a third column that contains the complete data.
Example:
df<-data.frame(UID = 1:8,
A = c("blue", NA, "blue", NA, "green", NA, "green", "green"),
B = c("blue", "blue", NA, "blue", NA, "green", NA, "green"))
I am looking for the third column to equal;
df$C<-c(rep("blue", 4), rep("green", 4))
I have tried using tidyr::unite
to no avail. I know this is probably a bad idea, LOL. I figure there is either a really simple answer or that it is not possible, LOL. Any help is much appreciated.