When trying to combine multiple character columns using unite from dplyr, the na.rm = TRUE
option does not remove NA.
Step by step:
- Original dataset has 5 columns
word1:word5
Image of the original data - Looking to combine
word1:word5
in a single column using code:
data_unite_5 <- data_original_5 %>%
unite("pentawords", word1:word5, sep=" ", na.rm=TRUE, remove=FALSE)
- Here's an image of the output: data_unite_5
- I've tried using
mutate_if(is.factor, as.character)
but that did not work.
Any suggestions would be appreciated.