ggmap
play

ggmap Available on CRAN! Recent Advances in Spatial Visualization - PDF document

ggmap Available on CRAN! Recent Advances in Spatial Visualization David J. Kahle, Ph.D. @ Department of Statistical Science B A Y L OR u n i v e r s i t y components of this talk 1. ggplot2 and the layered grammar of graphics 2. ggmap


  1. ggmap Available on CRAN! Recent Advances in Spatial Visualization David J. Kahle, Ph.D. @ Department of Statistical Science

  2. B A Y L OR u n i v e r s i t y components of this talk 1. ggplot2 and the layered grammar of graphics 2. ggmap basics ggmap = ggplot2 + online mapping sources 3. Some modeling Visualizing spatial interpolation 4. Utility functions Updates to geocode 5. Future directions David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  3. ggplot2 and the layered grammar of graphics

  4. the diamonds dataset B A Y L OR u n i v e r s i t y head(diamonds) ## carat cut color clarity depth table price x y z ## 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43 ## 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31 ## 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31 ## 4 0.29 Premium I VS2 62.4 58 334 4.20 4.23 2.63 ## 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75 ## 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48 David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  5. the diamonds dataset B A Y L OR u n i v e r s i t y Cut Ideal > Premium > Very Good > Good > Fair Color Clarity Internally Very Very Slightly Very Slightly Clarity Flawless Slightly Included Included Flawless Included Included Grade FL IF VVS1 VVS2 VS1 VS2 SI1 SI2 I1 I2 I3 x Everything else table width also y carat price z depth = z / diameter table = table width / x Source : http://www.a ff ordablediamondsonline.com/diamondshapes.jpg, http://beaufortsjeweler.com/images/diamond_color_chart.gif, http://www.am-diamonds.com/images/anatomy_diamond.gif David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  6. the diamonds dataset B A Y L OR u n i v e r s i t y head(diamonds) ## carat cut color clarity depth table price x y z ## 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43 ## 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31 ## 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31 ## 4 0.29 Premium I VS2 62.4 58 334 4.20 4.23 2.63 ## 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75 ## 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48 the diamonds dataset is pretty big, so let’s thin it down: library(dplyr) set.seed(1) d <- diamonds %>% sample_n(100) David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  7. the ggplot2 framework B A Y L OR u n i v e r s i t y plot(d$carat, d$price) ● ● ● ● 15000 ● ● ● ● ● 15000 ● ● ● ● ● ● ● ● ● ● ● ● ● 10000 ● ● ● 10000 d$price ● ● ● ● ● ● ● ● d$price ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 5000 ● ● ● ● ● ● ● 5000 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0 0.5 1.0 1.5 2.0 0.5 1.0 1.5 2.0 d$carat d$carat David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  8. the ggplot2 framework B A Y L OR u n i v e r s i t y plot(d$carat, d$price) ● ● library(ggplot2) ● 15000 theme_set(theme_bw()) ● ● ● ● ● ● ● ● qplot(d$carat, d$price) ● 10000 ● ● d$price ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 5000 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● 0 0.5 1.0 1.5 2.0 d$carat David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  9. the ggplot2 framework B A Y L OR u n i v e r s i t y plot(d$carat, d$price) ● ● ● ● library(ggplot2) ● ● 15000 15000 theme_set(theme_bw()) ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● qplot(d$carat, d$price) ● ● 10000 10000 ● ● ● ● d$price ● ● price ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● qplot(carat, price, data = d) ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 5000 5000 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ●● ● ● ● ● ● ● ● ● 0 0 0.5 0.5 1.0 1.0 1.5 1.5 2.0 2.0 d$carat carat David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  10. the ggplot2 framework B A Y L OR u n i v e r s i t y qplot(carat, price, data = d) ● ● ● ● qplot(carat, price, data = d, ● ● 15000 15000 ● ● geom = "point" ● ● ● ● ● ● ) ● ● ● ● ● ● ● ● ● ● 10000 10000 ● ● ● ● d$price ● ● price ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 5000 5000 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ●● ● ● ● ● ● ● ● ● 0 0 0.5 0.5 1.0 1.0 1.5 1.5 2.0 2.0 d$carat carat David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  11. the ggplot2 framework B A Y L OR u n i v e r s i t y qplot(carat, price, data = d) qplot(carat, price, data = d, geom = "point" 15000 ) 10000 qplot(carat, price, data = d, price geom = "smooth" ) 5000 0 0.5 1.0 1.5 2.0 carat David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  12. the ggplot2 framework B A Y L OR u n i v e r s i t y qplot(carat, price, data = d) qplot(carat, price, data = d, geom = "point" ) 10000 qplot(carat, price, data = d, price geom = "smooth" ) 5000 qplot(carat, price, data = d, geom = "density2d" ) 0 0.5 1.0 1.5 carat David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  13. the ggplot2 framework B A Y L OR u n i v e r s i t y qplot(carat, price, data = d) qplot(carat, price, data = d, ● ● geom = "point" ● 15000 ● ● ● ● ) ● ● ● ● qplot(carat, price, data = d, ● 10000 ● ● geom = "smooth" ● price ● ● ● ● ● ) ● ● ● ● ● ● qplot(carat, price, data = d, ● ● ● ● ● ● ● 5000 ● ● geom = "density2d" ● ● ● ● ● ● ● ● ● ) ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● qplot(carat, price, data = d, ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● 0 geom = c("density2d", "point") 0.5 1.0 1.5 2.0 carat ) David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

  14. list of geoms B A Y L OR u n i v e r s i t y The geom you use depends on your situation! abline bar histogram bin2d blank boxplot crossbar dotplot errorbar freqpoly hex hline linerange map density contour density2d path step point jitter pointrange polygon quantile raster rect ribbon rug segment smooth text tile violin vline See docs.ggplot2.org/current/ for details David J. Kahle, Ph.D. 45th Symposium on the Interface (2015) : Data Science

Recommend


More recommend