R for Reproducible Scientific Analysis

an introduction to R for non-programmers using gapminder data

ATTENTION

This is a modified version of the original lesson plan, tailored for UoR Carpentries workshop 27/07/2021.

The goal of this lesson is to teach novice programmers to write modular code and best practices for using R for data analysis. R is commonly used in many scientific disciplines for statistical analysis and its array of third-party packages. We find that many scientists who come to Software Carpentry workshops use R and want to learn more. The emphasis of these materials is to give attendees a strong foundation in the fundamentals of R, and to teach best practices for scientific computing: breaking down analyses into modular units, task automation, and encapsulation.

Note that this workshop will focus on teaching the fundamentals of the programming language R, and will not teach statistical analysis.

The lesson contains more material than can be taught in a day. The instructor notes page has some suggested lesson plans suitable for a one or half day workshop.

A variety of third party packages are used throughout this workshop. These are not necessarily the best, nor are they comprehensive, but they are packages we find useful, and have been chosen primarily for their usability.

Prerequisites

Understand that computers store data and instructions (programs, scripts etc.) in files. Files are organised in directories (folders). Know how to access files not in the working directory by specifying the path.

Schedule

Setup Download files required for the lesson
00:00 1. Introduction to R and RStudio How to find your way around RStudio?
How to interact with R?
How to manage your environment?
How to install packages?
00:55 2. Project Management With RStudio How can I manage my projects in R?
01:25 3. Seeking Help How can I get help in R?
01:45 4. Data Structures How can I read data in R?
What are the basic data types in R?
How do I represent categorical information in R?
02:40 5. Exploring Data Frames How can I manipulate a data frame?
03:10 6. Subsetting Data How can I work with subsets of data in R?
04:00 7. Control Flow How can I make data-dependent choices in R?
How can I repeat operations in R?
05:05 8. Vectorization How can I operate on all the elements of a vector at once?
05:30 9. Functions Explained How can I write a new function in R?
06:30 10. Data Wrangling with dplyr and tidyr How can I select specific rows and/or columns from a dataframe?
How can I combine multiple commands into a single command?
How can I create new columns or remove existing columns from a dataframe?
How can I reformat a dataframe to meet my needs?
07:50 11. Creating Publication-Quality Graphics with ggplot2 How can I create publication-quality graphics in R?
09:10 12. Producing Reports With knitr How can I integrate software and reports?
10:25 13. Command-Line Programs How do I write a command-line script?
How do I read in arguments from the command-line?
10:55 14. Writing Good Software How can I write software that other people can use?
11:10 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.