Since Nick's answer is deprecated by now and Rafael's comment is really useful, I want to add this as an Answer. If you want to change all factor
columns to character
use mutate_if
:
dat %>% mutate_if(is.factor, as.character)
Also other functions are allowed. I for instance used iconv
to change the encoding of all character
columns:
dat %>% mutate_if(is.character, function(x){iconv(x, to = "ASCII//TRANSLIT")})
or to substitute all NA
by 0 in numeric columns:
dat %>% mutate_if(is.numeric, function(x){ifelse(is.na(x), 0, x)})