as.character()1. Convert a factor (Var1) to a character
variable
Review the data (d1)
# A tibble: 3 x 5
Var1 Var2 Var3 Var4 Var5
<fct> <int> <dbl> <date> <lgl>
1 a 2 3.6 2004-10-10 TRUE
2 b NA 8.5 2007-12-14 FALSE
3 c 3 NA 2020-08-09 TRUE
View the class for Var1
class(d1$Var1)
[1] "factor"
Convert Var1 to a character.
dplyr::mutate() and saving over the original variable by
naming the new variable the same name as the original.d1 <- d1 %>%
dplyr::mutate(Var1 = as.character(Var1))
class(d1$Var1)
[1] "character"
Return to Data Types