Upload
agnes-armstrong
View
212
Download
0
Embed Size (px)
Citation preview
Graphing Parameters
TitlesX-Axis TitleY-Axis TitleLegendScalesColorGridlines
library(help="graphics")
Basic Chart Types
The R Graphics Package
LineHistogram
Scatter Box
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
formations
Legend Axes
Seven Components
The anatomy of a graph
ggplot2 Components
In ggplot2 a plot is made up of layers.
ggplot2
Pl o t
ggplot2: geomsCh4 Histogram Density Boxplot Scatter
Basic
Labels
Colors
http://docs.ggplot2.org/current/
ggplot2: histogram
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")
Scatterplot: NFL Example
rCharts: Scatterplot