Coding Club: Creating an R Package

Author

Lisa DeBruine

Overview

This book will serve as a record of the activities of the 2022 PsyTeachR Coding Club at the University of Glasgow School of Psychology & Neuroscience. It is in progress and will be updated regularly.

Making an R package develops generic coding skills and gives you valuable insight to how R works. We’ll cover setting up a package project, creating functions, documenting them with roxygen, creating vignettes, unit testing, package testing, version control with git, and distribution with github.

You will need only very basic R skills and a willingness to learn. The only people this would not be suitable for are those with zero previous experience in R (unless you know you pick up coding languages quickly). If you can install packages and have written an analysis script, you’ll be fine.

Register for free at EventBrite

Register to help us keep organised and let us know a little bit about your experience. Space is unlimited, so don’t worry if you can’t make all of the dates. We’ll record the sessions and make them public ASAP so you can catch up if you miss the live session.

Demo Package

This book contains all of the instructions to create your first R package. But if you fall behind and need to download the most recent version of the demopkg, visit https://github.com/psyteachr/demopkg and check the README for download instructions.

Tentative Schedule

The passcode for all recordings will be codingclub22!

  1. Setting up a package project (2022-10-05) Recording

    Create a package project and edit the default files. Well start using the most helpful package, usethis.

  2. Adding Data (2022-10-12) Recording

    Add datasets to your package and document them with a codebook. You can use our demo data or your own.

  3. Custom Functions (2022-10-19) Recording

    Learn to write custom functions and include them in your package.

  4. Documentation (2022-10-26) Recording

    Write function documentation using the roxygen format. This is what creates the help documentation for functions.

  5. Unit Tests (2022-11-02) Recording

    Write unit tests for your custom functions using testthat.

  6. Vignettes (2022-11-09) Recording

    Include your study analysis code as a package vignette.

  7. Pkgdown Websites (2022-11-16) Recording

    Create a package website using pkgdown.

  8. Package Maintenance (2022-11-23) Recording

    How to run CMD-check to make sure everything is put together right, and how to troubleshoot the inevitable problems.

No session 2022-11-30

The UK University and College Union (UCU) is planning industrial action on 2022-11-30, and Lisa is a union member, so this session will be delayed until 12-07, unless the universities propose a reasonable offer.

  1. Sharing your package (2022-12-07)

    Set up a github account and make a package repository to share your package and pkgdown website.

Resources