Intermediate-level programming with R
This lesson is for learners that are comfortable programming in R and want to learn some of R’s powerful tools for analyzing and visualizing data, literate programming, and debugging code.
The data used in this lesson are the citations and altmetrics for the PLOS journals from 2003-2010. The data set was compiled by Priem et al. 2012 (publication, code).
This lesson starts with a quick review of the basics of the Unix shell and programming with R.
Prerequisites
Learners should be familiar working in the Unix shell and basic programming with R, e.g. writing functions.
Getting ready
You’ll need to install the following packages: rmarkdown, dplyr, ggplot2, and testit.
Topics
- Setting up a project
- Inspecting a file
- Using RStudio
- Importing and inspecting data
- R conditional statements
- R loops
- Writing in Markdown
- Writing in R Markdown
- Using knitr chunk options
- Subsetting data with dplyr
- Using pipes with dplyr
- Starting with ggplot2 - Map data to plot aesthetics
- Control data mapping with scales
- Creating subplots with facets
- Creating different plots with geoms
- Debugging with debug
- Debugging with browser
- Defensive programming with stopifnot