Base package provides the simplest graphs: easy to remember, provides low level of analysis.
plot(), hist()…
Lattice is more options to create higher level of analysis.
Ggplot is also good for higher level of analysis.
plot: generic x-y plottingbarplot: bar plotsboxplot: box-and-whisker plothist: histogramspie: pie chartsdotchart: cleveland dot plotsimage, heatmap, contour, persp: functions to generate image-like
plotsqqnorm, qqline, qqplot: distribution comparison plotspairs, coplot: display of multivariant dataJury is still out on which is better
#install.packages('lattice') #if not installed already
require(lattice)
histogram(~mpg$hwy|mpg$year)
ggplot(mpg) +
geom_histogram(aes(x=hwy , fill=as.factor(year) )) +
facet_grid(~ year)
#histograms
histogram(~hwy, mpg)
#histograms
histogram(~hwy|year, mpg)
#histograms
histogram(~hwy|as.factor(year)+as.factor(cyl), mpg)
densityplot(~hwy|class, mpg)
densityplot(~hwy+cty|class, mpg)
qqmath(~hwy, mpg)
#conditional plot
qqmath(~hwy | class, mpg)
A.k.a. Box and whiskers plots. Hence the command bwplot()
bwplot(~hwy, mpg)
#conditional
bwplot(hwy~class, mpg)
#conditional
bwplot(hwy~class|as.factor(year), mpg)
Scatter plots
xyplot(hwy~cty, mpg)
xyplot(hwy~cty|manufacturer, mpg)
xyplot(hwy~cty|as.factor(displ), mpg)