Here, we will first use the qplot
function
for obtaining various kinds of plots. To keep the story short, we are using the earlier datasets only and hence, a reproduction of the similar plots using qplot
won't be displayed. The reader is encouraged to check ?qplot
and its examples.
Load the library with
library(ggplot2)
.Rearrange the resistivity dataset in a different format and obtain the boxplots:
test <- data.frame(rep(c("R1","R2"),each=8),c(resistivity[,1], resistivity[,2])) names(test) <- c("RES","VALUE") qplot(factor(RES),VALUE,data=test,geom="boxplot")
The
gplot
function needs to be explicitly specified that RES is a factor variable and according to its levels, we need to obtain the boxplot for the resistivity values.For the Gasoline dataset, we would like to obtain a boxplot of the mileage accordingly as the gear system could be manual or automatic. Thus, the
qplot
can be put to action withqplot(factor(x11),y,data=Gasoline,geom= "boxplot")
.A histogram...