Programming with R

This README is meant for Software Carpentry instructors planning to teach a intermediate level R bootcamp. Do not commit this readme as-is without editing.

This master set is based on material from a 2-day bootcamp (@karthik) ran in Canberra, Australia in October 2013. The material is meant to cover the full range of topics typically covered in a regular Python bootcamp.

Shell and Git are intentionally missing from this set. Please consult other lesson folders for those topics.

Topic Materials
Basics Introduction to R, data types, best practices, seeking help, Using the RStudio IDE
Functions Basics of control flow, scoping rules and functions in R
Data Manipulation A full introduction to the apply family, dealing with IO in R, and a full hands on example of cleaning messy data in R
Data Visualization A complete introduction to ggplot2
Testing Documentation with roxygen2, Unit testing with testthat
Reproducible Research knitr, make

Complete list of lessons

| Topic | Material | | —- | —— | | R Basics | 01-basics-of-R.Rmd
02-data-structures.Rmd
03-best-practices.Rmd
04-seeking-help.Rmd
05-subsetting.Rmd
06-vectorization.Rmd
best-practices.Rmd
rstudio-basics.Rmd | | Data Manipulation | 00-messy_data.Rmd
01-input-output.Rmd
02-apply-family.Rmd
03-split-apply.Rmd
| | Functions and Control Structures | 01-functions.Rmd
02-control_structures.Rmd
03-scoping_rules.Rmd
| | Data Visualization
If you make changes, only edit the .Rnw file.
Then knit and tagle to generate other two files
| ggplot.R (tangled code from source)
ggplot.Rnw (source)
ggplot.pdf (rendered)
| | Reproducible Research | knitr.Rmd
make.md
markdown.md
| | Testing and Documentation | documentation.md
testing.Rmd
|

Note: You will not be able to teach all topics in 2 days, especially since the above table does not include Git or Shell. So you will have to drop Reproducible research or Testing/documentation (or both) depending on audience skill level and interest.

Package installation

Participants will require the following packages. Please transfer these instructions to your installation instructions page.

coffee install.packages("devtools") # You'll need other non-R dependencies before you can install devtools. Please see the additional_software.md page for more instructions. install.packages(c("reshape2", "plyr", "ggplot2", "knitr", "testthat", "assertthat", "stringr", "pander"))

Notes for instructor teaching with this material.

  • Please pull from the bc repo and decide what topics within R you would like to cover. Then retain the necessary folders and delete the rest. It might also help to number section folders in the order in which you might cover the material.

  • Next, knit all of the Rmd files in each folder to make sure they parse correctly. Please avoid doing this the night before you teach in case any material needs to be updated to keep up with package changes.

  • Commit the rendered files to your repo (NOT bc) so you have material to show on the projector while you teach. You might also consider doing a sed replacement for ```r to coffee for better syntax highlighting.

  • If you decide to teach Make in the context of knitr, please ensure that Make is correctly installed on all computers (see additional software under R-basics) section. Also keep in mind that the material here is intentionally sparse. There will be material in other lesson folders with more details that you might want to pull in.