100 likes | 213 Views
The R Graphics Package. Graphing Parameters. Basic Chart Types. Histogram. Line. Titles X-Axis Title Y-Axis Title Legend Scales Color Gridlines. Scatter. Box. library(help="graphics"). Histogram of NFL Offense.
E N D
The R Graphics Package • Graphing Parameters • Basic Chart Types Histogram Line Titles X-Axis Title Y-Axis Title Legend Scales Color Gridlines Scatter Box library(help="graphics")
Histogram of NFL Offense hist(nfl$OffPtsA,freq=F, breaks = 25, ylim = c(0,0.14), col = "blue") curve(dnorm(x, mean=mean(nfl$OffPtsA), sd=sd(nfl$OffPtsA)), col="purple", add=T)
Grammar of Graphics Seven Components formations Legend Axes
ggplot2 Components The anatomy of a graph
ggplot2 In ggplot2 a plot is made up of layers. Pl o t
ggplot2: geoms http://docs.ggplot2.org/current/
Histograms: NFL Example • Create the plot object: nflHistogram <- ggplot(nfl, aes(OffPtsA)) + opts(legend.position = "none") • Add the graphical layer: nflHistogram+ geom_histogram(binwidth = 0.4 ) + labs(x = "NFL Offense Points", y = "Frequency")