I mostly use packages that are a part of the tidyverse or which work well with the tidyverse (e.g., sf). The R universe has lots of great resources on those and other topics. Here are some that I’d recommend:
For general data wrangling and other data management in the tidyverse (dplyr and other tidyverse packages)
Tidyverse home page: https://www.tidyverse.org/
dplyr home page: https://dplyr.tidyverse.org/
R for Data Science: https://r4ds.had.co.nz/.
This book by Hadley Wickham and Garrett Grolemund is the authoritative guide for learning dplyr and other tidyverse packages.
The chapter on dplyr specifically is https://r4ds.had.co.nz/transform.html.
Tips for using dplyr by Dr. Michael Kramer, an Emory colleague, as part of his course on Spatial Epidemiology: https://mkram01.github.io/EPI563-SpatialEPI/dplyr.html
For importing rectangular data (e.g., CSV) using readr: https://readr.tidyverse.org/
For explanation of more “under-the-hood” technical topics, I would suggest https://adv-r.hadley.nz/
For manipulating (vector-based) spatial data (sf)
sf home page: https://r-spatial.github.io/sf/index.html
sf vignettes (1-5), e.g., https://r-spatial.github.io/sf/articles/sf1.html
sf cheatsheet: https://github.com/rstudio/cheatsheets/blob/main/sf.pdf
Geocomputation with R (Lovelace, Nowosad, Muenchow) : https://geocompr.robinlovelace.net/
Key chapters on managing sf:
This book also covers raster data and corresponding packages (terra and raster).
Chapter on sf in Spatial Data Science (Pebesma, Bivand): https://keen-swartz-3146c4.netlify.app/sf.html#sfintro
Tips for working with sf by Dr. Michael Kramer: https://mkram01.github.io/EPI563-SpatialEPI/sf-overview.html
For making charts and figures (ggplot2)
ggplot2 home page: https://ggplot2.tidyverse.org/
cookbook: http://www.cookbook-r.com/Graphs/
ggplot2 cheat sheet: https://raw.githubusercontent.com/rstudio/cheatsheets/main/data-visualization.pdf
Data visualization principles: book (not free) by Kieran Healy, https://kieranhealy.org/publications/dataviz/
For making maps (mapview, tmap, ggplot2)
Chapter on making maps in Geocomputation with R: https://geocompr.robinlovelace.net/adv-map.html
Mapview is my favorite mapping package, in part for its simplicity.
Its home page is https://r-spatial.github.io/mapview/
Several vignettes are available on that page, e.g., https://r-spatial.github.io/mapview/articles/mapview_01-basics.html
Tmap is another widely used mapping package and can create both static and interactive maps.
ggplot2 can also be used to make static maps of sf objects:
Chapter in Spatial Data Science: https://keen-swartz-3146c4.netlify.app/plotting.html#geomsf
Color palettes:
viridis: https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html
Note viridis is often the default option in mapview.
Note viridis is built into some ggplot2 functions.
RColorBrewer:
website to see color palettes: https://colorbrewer2.org/
R package: https://cran.r-project.org/web/packages/RColorBrewer/index.html
Other miscellaneous resources I frequently use and reading I recommend:
RStudio cheatsheets on dplyr, ggplot2, and more: https://www.rstudio.com/resources/cheatsheets/
For downloading free or open-source data into R:
Downloading census data (tidycensus): https://walker-data.com/tidycensus/
Downloading OpenStreetMap data (osmdata): https://cran.r-project.org/web/packages/osmdata/vignettes/osmdata.html
R Markdown:
R Markdown, the Definitive Guide: https://bookdown.org/yihui/rmarkdown/
R Markdown Cookbook: https://bookdown.org/yihui/rmarkdown-cookbook/
On managing working directory and organizing projects:
Jenny Bryan on the importance of a project-oriented workflow: https://www.tidyverse.org/blog/2017/12/workflow-vs-script/
Jenny Bryan’s Ode to the here package: https://github.com/jennybc/here_here
Folder structure of R projects: https://chrisvoncsefalvay.com/2018/08/09/structuring-r-projects/
The Epidemiologist R Handbook: https://epirhandbook.com/en/index.html
This is an online book whose target audience is public-health professionals and epidemiologists.
It has a chapter on transitioning to R targeting those who primarily use Excel, SAS, or STATA: https://epirhandbook.com/en/transition-to-r.html
RStudio keyboard shortcuts:
https://support.rstudio.com/hc/en-us/articles/200711853-Keyboard-Shortcuts-in-the-RStudio-IDE
The two keyboard shortcuts I use the most are:
Operation | Mac | Windows & Linux |
---|---|---|
Run current line / selection | cmd+return | ctrl+enter |
Insert pipe (%>% ) |
cmd+shift+m | ctrl+shift+m |
Copyright © 2022 Michael D. Garber