September 2018
Beginner
206 pages
4h 27m
English
We input a few variables from mtcars into plot(), but they were continuous. What happens if, instead, we input a factor variable?
For example, the cyl variable in mtcars gives the number of cylinders each car has. If we input it as a factor variable into plot, we get a bar chart (histogram) by default, where each bar gives a count of how many cars have each number of cylinders:
plot(as.factor(mtcars$cyl))

Let's now create plots using factor variables and learn to differentiate between plots created with factor variables and those created without. Follow the steps given below: