September 2018
Beginner
206 pages
4h 27m
English
The recode() function, available in the dplyr package, can change the level of the factor by using more readable code, as follows:
library(dplyr)iris$Species3 <- recode(iris$Species, "setosa" = 1, "versicolor" = 2, "virginica" = 3)
These are both valid options, and which one you use is up to you.
Read now
Unlock full access