1 / 10

Visualizing NFL Offense Points: Histograms and Scatterplots with R's ggplot2

This guide explores the visualization of NFL offense points using R's graphics package, focusing on histograms and scatterplots. It demonstrates how to create a histogram of NFL offense points and overlay a normal distribution curve to illustrate data distribution. The use of ggplot2 is highlighted, showcasing how to create layered graphics with customized titles, axes labels, and legends. Key parameters such as binwidth, colors, and gridlines, are also addressed, enabling clear representation of statistical data for better insights into NFL offenses.

opal
Télécharger la présentation

Visualizing NFL Offense Points: Histograms and Scatterplots with R's ggplot2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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")

  2. 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)

  3. Grammar of Graphics Seven Components formations Legend Axes

  4. ggplot2 Components The anatomy of a graph

  5. ggplot2 In ggplot2 a plot is made up of layers. Pl o t

  6. ggplot2: geoms http://docs.ggplot2.org/current/

  7. ggplot2: histogram

  8. 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")

  9. Scatterplot: NFL Example

  10. rCharts: Scatterplot

More Related