September 2018
Beginner
206 pages
4h 27m
English
The following code can be used to load the datasets library:
library(ggplot2)
The following code can be used to create a histogram to plot petal width:
ggplot(iris, aes(Petal.Width)) + geom_histogram(binwidth = 0.5)
The following code can be used to create a scatterplot to plot petal length and width:
ggplot(iris, aes(Petal.Width, Petal.Length)) + geom_point()
The following code can be used to create a boxplot to plot petal length and the Species factor variable:
ggplot(iris, aes(as.factor(Species), Petal.Width)) + geom_boxplot()
The following code can be used to create a bar chart using the gear variable of the mtcars dataset:
ggplot(mtcars, aes(gear)) + geom_bar()
Read now
Unlock full access