Introduction to R

Topics included the framework of R as a language, the building blocks of that language (objects as nouns, functions as verbs), and basic functions, data wrangling with dplyr, visualization with ggplot2, psychometrics with psych, simple descriptive and inferential statistics, and workflow integration and reproducibility with Markdown. Workshop times ranged from 2 to 9 hours


Workshops designed for audiences already familiar with basic statistical analyses, data wrangling, and visualization.

  • An introduction to R. Presented at the Social and Behavioral Sciences Research Initiative at the University of Illinois in Urbana-Champaign. (November 3, 2017).
  • An introduction to R. Presented at the Association for Psychological Science Annual Conference. (May 2015 - New York; May 2016 - Chicago; May 2017 - Boston). Developed by William Revelle; Co-presented with William Revelle and David Condon.

Workshops designed for an audience unfamiliar with statistical analyses.

  • An introductory workshop to RPresented to first-year psychology graduate students during orientation at Washington University in St. Louis. (August 2015 and August 2016)Co-developed with Debbie Yee.
  • Introduction to R workshop. APA-sponsored summer research program for underrepresented minority undergraduates, presented at Washington University in St. Louis. (June and July 2016). Co-developed with Shelly Cooper.
Below is a function I wrote to help format numbers in manuscripts. I use R Markdown and knitr frequently, both for supplementary material files documenting my code and, more recently, to write the actual manuscript. This function helps format numbers to comply with APA format. The default is to round to 2 digits (this can be changed with the digits argument). Importantly, this keeps any 0's in the tenth and hundredth place (e.g., 1.90 instead of 1.9). Alternatively, you can include the argument int = TRUE and the number will be treated as an integer, with no decimal places and with commas in appropriate places.
num <- function(x, digits=2, int=F){
  num_internal = function(x = x){
    if(is.character(x)) x = as.numeric(x)
    if(int == TRUE) digits = 0
    if(int == FALSE) y <- prettyNum(round(x,digits))
    if(int == TRUE) y <- prettyNum(round(x),big.mark=",")
    if(grepl("\\.",y)) z <- strsplit(y, "\\.")
    if(grepl("\\.",y) & int == F){
      y <- paste0(y, 
    } else if (!grepl("\\.",y) & int == F & digits != 0){
      y <- paste0(y,".", paste(rep(0,digits), collapse=""))
  if(length(x) == 1){
    num_internal(x) } else sapply(x, num_internal)