Jay Achar

Doctor. Researcher. Developer.

Installing R

Getting started in R requires installing two pieces of software. If you have sufficient permissions on your computer the process is straightforward and quick. But why would you want to install more software on your computer? What does programming in R offer you?

What is R?

R was originally designed as a programming language for running statistical analyses by two New Zealanders in the 1990s. It's generally thought of as a Domain Specific Language rather than a general purpose language such as Python, Javascript or Rust. However, while it may not be optimised for the wide variety of use-cases these other languages cover, it does have the capability to create applications, run servers, automate tasks and generate attractive visualisations.

How does R compare to Excel or Stata?

Excel is an excellent tool for getting started with data collection, or with analysis. Information can be shared quickly through the Microsoft ecosystem, and data updated by almost anyone with access to a file. One of the pitfalls with using Excel for research is this openness. While Excel does have many options for restricting editing rights, including data validation and ensuring robust data structures, by default, most of these options are switched off. Most Excel-based workflows are therefore based on manual configuration, are prone to complex errors being introduced accidentally and struggle to integrate with other tools which allow for automation, computation speed and more robust handling of errors.

The comparison with Stata, or other statistical programmes is more nuanced and, to be honest, many researchers prefer to use other statistical programmes either because that's what they've always used, or they receive more support from their institution, or they simply prefer the approach taken by their chosen software.

However, R does have some advantages even if there is a learning curve to be navigated. First of all, R is absolutely free - no licence, no expensive training courses. There's an abundance of free information available for R online and the R community is generally very welcoming towards new-comers.

R is extensible through the numerous packages that have been created by users. You can create your own packages for the unique statistical tasks you need to perform frequently. This extensibility allows for the diverse use-cases for R mentioned above.

Working in R and following a few best-practices will also dramatically improve the reproducibility of your analysis. This allows for easier collaboration and sharing of methods and results.

Ultimately, the choice of statistical programme you want to use will be dependent on your circumstances and your use-case.

Getting started

The most common approach to get started is to download and install R and RStudio, a tool for writing and running your R code.

  1. Go the Posit site and click the Download and Install R button. At the top of the linked page, you click the link to download R for your operating system. If you're using Windows, choose the base option on the following page. If you're using macOS, choose the version that aligns with the type of Mac you are using.
  2. Install the downloaded R file as you would any other software on your computer.
  3. Return to the Posit site and click the button to Download RStudio Desktop. Install RStudio by double-clicking the downloaded file.

If all went well, you should now be ready to write some code in R. Type the following into the panel marked Console, then press enter.


Sys.Date()

If you see today's date, then you've successfully installed R and RStudio. Congratulations.