Skip to content

ICS02: 8. Introduction to R

Gabriel Bodard edited this page Mar 5, 2019 · 30 revisions

Sunoikisis Digital Classics, Spring 2019

Session 8. Introduction to programming through R

Thursday Feb 28, 16:00 UK = 18:00 EET

Convenors: Christopher Ohge & Gabriel Bodard (University of London)

YouTube link:

Access the R notebook

Access the HTML version of the R notebook, with the visualisations

Session outline

This session will introduce basic programming concepts with the R language. After an introductory lesson on regular expressions, R syntax, and basic R functions, we will use the tidy text library package to perform text analysis tasks.


  1. Intro: common programming languages in DH
  2. Regular expressions
  3. Intro to R and tidytext

Installing R and RStudio

Before the session, make sure to download the R software package from

  • Click on "download R."
  • Choose the appropriate CRAN mirror in your area for downloading (for me it's the UK > Imperial College London link).
  • Download and install the appropriate R 3.5.2 binary for your operating system.

Then download the latest version of RStudio at

  • Click on "Download RStudio."
  • Download the RStudio Desktop (free) version.
  • Chose the appropriate installer: Most of you will use either RStudio 1.1.463 - Windows Vista/7/8/10 or Mac OS X 10.6+.

Seminar readings

Further reading

Other resources

Essay title

  • tba


  1. Create a regular expression to remove those non-words in dickens.words.v.

  2. Create a regular expression for only dialogue words in dickens.words.v. Modify the Jockers for loop by confining your word frequency results to only dialogue.

  3. Using the gutenbergr package, load some new text files (more than one, please) that interest you. Create a tidy tibble of the textual data and chose a visualisation method for displaying your results.

  4. Based on your results, posit a new question--or questions--about what you would like to investigate further. Modify a code block(s) from Part I of the R Notebook to answer your question.