Your SlideShare is downloading. ×
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Tech talk   ggplot2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Tech talk ggplot2

1,513

Published on

A quick introduction to the ggplot2 R package by Hadley Wickham which implements the Grammar of Graphics paradigm in the R language.

A quick introduction to the ggplot2 R package by Hadley Wickham which implements the Grammar of Graphics paradigm in the R language.

Published in: Entertainment & Humor
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,513
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
78
Comments
0
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Slides adapted/stolen from Garret Grolemund/RStudio’s Data Visualization Courseggplot2 Jeff Allen Quantitative Biomedical Research Center 3.18.13
  • 2. Getting Startedinstall.packages(c("ggplot2", "hexbin", "ggmap", "maps", "RColorBrewer", "scales","ReadImages"))library(ggplot2)library(hexbin)library(ggmap)library(maps)library(RColorBrewer)library(scales)library(ReadImages)
  • 3. Grammar of Graphics• Framework for describing visualized data – Mapping data onto a coordinate system• Created by Leland Wilkinson
  • 4. Your First ggplot2 Plot> library(ggplot2)> head(mpg) manufacturer model displ year cyl trans drv cty hwy fl class1 audi a4 1.8 1999 4 auto(l5) f 18 29 p compact2 audi a4 1.8 1999 4 manual(m5) f 21 29 p compact3 audi a4 2.0 2008 4 manual(m6) f 20 31 p compact4 audi a4 2.0 2008 4 auto(av) f 21 30 p compact5 audi a4 2.8 1999 6 auto(l5) f 16 26 p compact6 audi a4 2.8 1999 6 manual(m5) f 18 26 p compact
  • 5. Your First ggplot2 Plotggplot(data=mpg, aes(x=cty, y=hwy)) + geom_point()
  • 6. Your First ggplot2 Plot Thedata.frame to plotggplot(data=mpg, aes(x=cty, y=hwy)) + geom_point()
  • 7. Your First ggplot2 Plot Thedata.frame Aesthetic to plot Mappingsggplot(data=mpg, aes(x=cty, y=hwy)) + geom_point()
  • 8. Your First ggplot2 Plot Thedata.frame Aesthetic to plot Mappingsggplot(data=mpg, aes(x=cty, y=hwy)) + geom_point()What geom to use in plotting
  • 9. Your First ggplot2 Plotlibrary(ggplot2)ggplot(data=mpg, aes(x=cty, y=hwy)) + geom_point()
  • 10. ImprovementsProblem: verbosityggplot(data=mpg, aes(x=cty, y=hwy)) + geom_point()ggplot(mpg, aes(cty, hwy)) + geom_point()
  • 11. ImprovementsProblem: OverplottingSolution: Different geomsggplot(mpg, aes(cty, hwy)) + geom_jitter()
  • 12. ImprovementsProblem: OverplottingSolution: Different geomsggplot(mpg, aes(cty, hwy)) + geom_bin2d()
  • 13. Colors & Groupsggplot(mpg, aes(cty, hwy, color=drv)) + geom_jitter()
  • 14. Colors & Groupsggplot(mpg,aes(drv, hwy)) + geom_boxplot()
  • 15. Adding Layersggplot(mpg,aes(drv, hwy)) + geom_jitter() + geom_boxplot()
  • 16. Adding Layersggplot(mpg, aes(cty, hwy)) + geom_jitter() + geom_smooth()
  • 17. Adding Layersggplot(data, aes(TIME, Y, color=GROUP)) + geom_line() + geom_smooth()
  • 18. Facetingggplot(mpg, aes(cty, hwy)) + geom_jitter() + facet_grid(drv ~ class)
  • 19. Refining Plotsggplot(mpg, aes(cty, hwy)) + geom_jitter() + xlab("City MPG") + ylab("Hwy MPG") + ggtitle("City vsHighway MPG")
  • 20. Etc.
  • 21. Etc.
  • 22. Etc.
  • 23. Etc.
  • 24. Etc.
  • 25. Etc.
  • 26. Etc.
  • 27. Etc.
  • 28. Resources• http://docs.ggplot2.org/• Google Group• ggplot2 Book

×