Summary and Setup

This is an introduction to R and RStudio designed for music researchers with no programming experience. The lesson aims to showcase how an individual might find R useful for their music research. Some initial information about the R syntax and navigating the RStudio interface are given, followed by information about how to import CSV files, clean your data, look at subsets of your data, carry out some initial statistical calculations, visualising different elements of your data, and finally, present some best practices when writing code in R.

Two example case studies are used in this lesson, featuring two types of web data sets - by no means does this lesson present an exhaustive list of the uses of R. The case studies presented are two of several potential use cases of how an individual may use R for their research and to work with data.

The main aim is to give a taste of what R can do for music researchers, and hopefully encourage researchers to consider R as one of multiple useful tools in their tool kit when it comes to working with data for their music research.

Prerequisite

  • This lesson requires R and RStudio to be installed on the learner’s device.
  • The two dummy data set files need to be downloaded in preparation for this lesson.

Software Setup


R and RStudio Setup Instructions

First, download and install R, and then download and install RStudio. Setup may vary slightly across systems. Different setup instructions based on whether your system is Windows, MacOS, or Linux may be access via the dropdown menus below.

  • Download R from the CRAN website
  • Run the .exe file that was just downloaded.
  • Go to the RStudio download page.
  • Press on the ‘Download RStudio’ button. This will direct you to the installation set up with 2 steps.
  • Step 1 is installing R which you will have already done, so skip that and go to Step 2.
  • Scroll down the web page to the Installers tab and download the Windows version of RStudio.
  • Double click the file to install it.
  • Once installed, try opening RStudio Desktop to check that it works.
  • Go to the CRAN website and select the .pkg file for the latest R version, based on your Mac’s processor.
  • Please note that there are two different packages depending on if your Mac has an Apple silicon processor (M1/M2 chip) or works with an Intel processor.
  • You can check your Mac’s processor type by clicking on the Apple icon at the upper left corner and clicking on About This Mac.
  • Download the relevant .pkg file and double click to install it.
  • Go to the RStudio download page.
  • Press on the ‘Download RStudio’ button. This will direct you to the installation set up with 2 steps.
  • Step 1 is installing R which you will have already done, so skip that and go to Step 2.
  • Scroll down the web page to the Installers tab and download the latest RStudio version for Mac.
  • Double click the file to install it.
  • Once installed, try opening RStudio Desktop to check that it works.
  • Go to the CRAN website and follow the instructions for your distribution to download and install R.
  • After R is installed, go to the RStudio download page.
  • Under Installers select the version that matches your distribution, and install it with your preferred method.
  • Once installed, open RStudio to make sure it works.

The RStudio environment is what we will be working in during this lesson.

Data Sets


Download the data-files folder and put it on your Desktop.