Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time

R course material

This page contains a collection of R tutorials, developed at the Vrije Universiteit Amsterdam for Communication Science courses that use R.

The goal is to organize relevant material into modular components, for more efficient design and maintenance of material, that can be used across courses, and that are accessible to students during and after their studies.

Below we list the relevant handouts/tutorials. Each links to the md file, see the Rmd file with the same name for the source code of the tutorials.

R Basics

Data mangling in the tidyverse

This is a set of tutorials designed to teach using the tidyverse functions for data cleaning, reshaping, visualizing etc. This includes handouts, which are documents that explain the most relevant commands, and also video tutorials that discuss the same material (note that it is  possible that the video tutorial is a bit older than the handout). The table also lists chapters from Computational Analysis of Communication (CAC) and R for Data Science (R4DS), two 100% free and open access books that discuss the material. Finally, it links to relevant RStudio cheat sheets, which are great resources to get an overview of the most relevant commands in a package.

Note that CAC has R and Python examples side by side, so that might be an interesting source. Als note that CAC is co-authored by two CCS.Amsterdam members, so all feedback is welcome!

Handout Video Tutorial CAC ch. R4DS ch. Core packages / functions
Fun with R Fun with R 2 3
R Basics Intro to R 3 4 base R
Transforming Data Importing and Cleaning 6 5 dplyr: filter, select, arrange, mutate
Summarizing Data Grouping and Summarizing 6.3 5 dplyr: group_by, summarize
Visualizing Data ggplot 1 7 7 ggplot2
Reshaping data Reshaping 6.5 12 tidyr
Combining (merging) Data Joining 6.4 13 dplyr: inner_join, left_join, etc.
Basic string (text) handling 9 14 stringr

Statistical Analysis

Frequentist Statistics

This is a set of tutorials designed to teach basic (Frequentist) statistical modeling and analysis. The first tutorial includes examples for standard regression analysis as well as analysis of variance. Later tutorials exemplify the use of more advanced statistical modelling approaches including the generalized linear model and multilevel models.

Tutorial Video tutorial Core packages / functions
Basic statistics Basic stats stats: lm, aov, t.test
Advanced statistics overview see GLM and Multilevel stats: glm, lme4: lmer, glmer
Generalized linear models GLM (on family argument) stats: glm, family, sjPlot: tab_model, plot_model
Multilevel Models Multilevel lme4: lmer, glmer, sjPlot: tab_model, plot_model
Structural Equation Modeling lavaan: sem, fitMeasures, parameterEstimates
Simple Mediation Analysis boot: boot, lavaan: sem, mediation: mediate
Specification Curve Analysis specr: setup_specs, run_specs, plot_specs...

Power Analyses and Simulations

Tutorial Video tutorial Core packages / functions
Power analyses for bivariate regression analysis stats: rnorm; pwr: pwr.r.test; tidyverse: various
Power analyses for t-tests stats: rnorm; pwr: pwr.t.test; tidyverse: various
Power analyses for exprimental designs (e.g., 2x2 between-subject) stats: rnorm;tidyverse: various; MonteCarlo: MonteCarlo

Test theory and factor analysis

The following tutorials can be used to teach basics of test theory and particularly confirmatory and exploratory factor analysis approaches.

Tutorial Video tutorial Core packages / functions
Classical Test Theory: Confirmatory Factor Analysis CFA in R psych: describe, mardia; lavaan: cfa, fitMeasures, modindices; semTools: reliability
Classical Test Theory: Exploratory Factor Analysis EFA in R psych: describe, mardia, fa.parallel, nfactors, fa, fa.diagram, omega
Item Response Theory: 3PL, 2PL, & 1PL/Rasch models mirt: mirt; ggmirt: various
Item Response Theory: Graded Response Model mirt: mirt; lavaan: cfa, standardizedsolution; ggmirt: various

Bayesian Statistics

This set of tutorials introduces the basics of Bayesian Statistics.

Tutorial Video tutorial Core packages / functions
Basics of Bayesian Statistics None
Bayesian Regression Analysis brms: brm, as_draw_df; bayestestR: various

Text analysis

For a general introduction to text analysis (in R), see these videos on preprocessing and different analysis approaches


See also the open access book, Text Mining with R: A TidyText approach by TidyText creators Julia Silge and David Robinson.

Tutorial Video tutorial Core packages / functions
TidyText basics tidytext, tidyverse
Dictionary analysis with TidyText tidytext, tidyverse, tokenbrowser, boolydict
Topic Modeling with TidyText tidytext, tidyverse, topicmodels

(Mostly) Quanteda-based

Tutorial Video tutorial Core packages / functions
Text analysis corpus stats quanteda
Lexical sentiment analysis dictionaries quanteda, corpustools
LDA Topic Modeling Video series, Tutorial demo topicmodels,quanteda
Structural Topic Modeling Variants of Topic Models; Structural Topic Models stm, quanteda
NLP Preprocessing with Spacy(r) spacyr, quanteda (see also spacy itself)
Supervised machine learning for text classification Supervised Machine Learning caret
Creating a topic browser with LDA corpustools

Data collection

Tutorial Video tutorial Core packages / functions
Gathering Data tidyverse, jsonlite
Webscraping with rvest Web scraping in R rvest

Note on installing packages

In general, most R packages can be installed without any issues. However, there are some exceptions that you need to know about. For quanteda (that we use in the text analysis tutorials), your computer needs certain software that is not always installed, as mentioned on the quanteda website. You can either install this software, but we rather recommend using R version 4.0.0 (or higher) where this is no longer required. To see your current R version, enter version in your R console. To update, visit the R website (Windows, Mac).

When running install.packages() You sometimes get the message that There is a binary version available but the source version is later (we're mainly seen this on Mac). You then get the question whether you want to install from sources the package which needs compilation (Yes/no) . To answer this question, you have to type "yes" or "no" in your R console. Most often, you'll want to say no. Simply put, R tells you that it has a new version of a package, but if you want to use it your computer will need to build it. The problem is that this requires some development software that you might not have installed. If you say no, you'll install an older version that has already been build for you. In rare cases, installing from source is the only way, in which case you'll have to install the software that R refers to.



A collection of R tutorials







No releases published


No packages published

Contributors 4