Statistics for Corpus Linguists
  • Overview
  • Introduction to R
    • 1.1 First steps
    • 1.2 Exploring R Studio
    • 1.3 Vectors
    • 1.4 Data frames
    • 1.5 Libraries
    • 1.6 Importing/Exporting
  • NLP
    • 2.1 Concordancing
    • 2.2 Regular expressions
    • 2.3 The CQP interface
    • 2.4 Data annotation
  • Statistics
    • 3.1 Data, variables, samples
    • 3.2 Probability theory
    • 3.3 Descriptive statistics
    • 3.4 Hypothesis testing
    • 3.5 Chi-squared test
    • 3.6 t-test
    • 3.7 ANOVA
    • 3.8 Case study
  • Models
    • 4.1 Linear regression
    • 4.2 Logistic regression
    • 4.3 Poisson regression
  • Machine Learning
    • 5.1 Tree-based methods
    • 5.2 Gradient boosting
  1. 1. Introduction to R
  2. 1.1 First steps
  • 1. Introduction to R
    • 1.1 First steps
    • 1.2 Exploring R Studio
    • 1.3 Vectors
    • 1.4 Data frames
    • 1.5 Libraries
    • 1.6 Importing/Exporting

On this page

  • Why learn R to begin with?
  • Installing R
  • Installing RStudio

Other Formats

  • PDF
  1. 1. Introduction to R
  2. 1.1 First steps

1.1 First steps

Author
Affiliation

Vladimir Buskin

Catholic University of Eichstätt-Ingolstadt

Abstract
This unit outlines why R is worth learning for corpus-linguistic research and guides you through installing R and RStudio.

Why learn R to begin with?

When it comes to data analysis, learning R offers an overwhelming number of short- and long-term advantages over conventional spreadsheet software such as Microsoft Excel or LibreOffice Calc:

  • First of all, it’s completely free. There’s no need to obtain any expensive licences, as is the case for commercial software such as SPSS or MS Excel.

  • R makes it very easy to document and share every step of the analysis, thereby facilitating reproducible workflows.

  • Large (and by that I mean extremely large!) datasets pose no problems whatsoever. Loading tabular data with hundreds of thousands (or even millions) of rows takes only a few seconds, whereas most other software would crash.

  • There are numerous extensions that provide tailored functions for corpus linguistics, which aren’t available in general-purpose spreadsheet software. These allow us to work with corpora, use complex search expressions, perform part-of-speech annotation and dependency parsing, and much more – all from within R.

  • The ggplot2 package offers an incredibly powerful framework for data visualisation. Not convinced? Check out the ggplot2 gallery.

  • The CRAN repository features more than 20,000 packages that can be installed to expand the functionality of R almost indefinitely. Should none of them meet your needs, R gives you the tools to write and share your own functions and packages with ease.

Installing R

The first step involves downloading the R programming language itself. The link will take you to the homepage of the Comprehensive R Archive Network (CRAN), where you can download the binary distribution. Choose the one that corresponds to your operating system (Windows, macOS or Linux).

Installation instructions for Windows users

Click “Download R for Windows” \(\rightarrow\) Select “base” \(\rightarrow\) Click on “Download R-4.4.1 for Windows” (or whichever version is currently displayed).

Open the setup file you’ve just downloaded and simply follow the on-screen instructions. It’s fine to go with the default options.

Video tutorial on YouTube

Installation instructions for macOS users

Click “Download R for macOS” \(\rightarrow\) Select the latest release for your Mac. Note that there are separate versions for Macs with Apple silicon (M1, M2, etc.) and for older Macs with Intel processors.

Open the downloaded .pkg file and follow the instructions in the installation window.

Video tutorial on YouTube

Installing RStudio

You can now download and install RStudio. RStudio is a so-called ‘integrated development environment’ (IDE), which provides us with a variety of helpful tools for writing and editing code comfortably. If R were a musical instrument, RStudio would be the recording studio, so to speak.

1.2 Exploring R Studio