# Convert cyl column from a numeric to a factor variable mtcars$cyl <- as.factor(mtcars$cyl) head(mtcars)