2  Setting Up Your Computer

Published

April 17, 2024

2.1 Objectives

  • Set up RStudio, R, Quarto, and python
  • Be able to run demo code in R and python

2.2 What are you asking me to install?

It’s generally a good idea to be skeptical when someone is telling you to install things. 🤨 Here’s a very broad overview of what each of these programs or services does and why I’m asking you to install or sign up for them.

What each program does, in general terms
Program Logo Purpose
R A statistical programming language built around working with data
Python A general-purpose programming language that is popular for machine learning tasks.
RStudio IDE An integrated desktop environment created to make it easy to work with R, Python, and other data-science programming tools.
Quarto A document creation system based on pandoc. Quarto allows you to include code, results, and pictures generated from data within a document so that they automatically update when the document is recompiled.
Git A version control system used to track changes to files.
GitHub An online collaboration platform based on git that makes it easy to back up, share, and collaborate on programming projects.

2.3 Installation Process

In this section, I will provide you with links to set up various programs on your own machine. If you have trouble with these instructions or encounter an error, post on the class message board or contact me for help.

  1. Download and run the R installer for your operating system from CRAN:

    If you are on Windows, you should also install the Rtools4 package; this will ensure you get fewer warnings later when installing packages.

    More detailed instructions for Windows are available here

  2. Download and install the latest version of python 3

    • Windows: check the box that asks if you want to add Python to the system path. This will save you a lot of time and frustration. If you didn’t do this, you can follow these instructions to fix the issue (you’ll need to restart your machine).

    • If you’re interested in python, you should install Jupyter using the instructions here (I would just do pip3 install jupyterlab)
      We will not use jupyter much in this book - I prefer quarto - but the python community has decided to distribute code primarily in jupyter notebooks, so having it on your machine may be useful so that you can run other people’s code.

    • Additional instructions for installing Python 3 from Python for Everybody if you have trouble.

  3. Download and install the latest version of RStudio for your operating system. RStudio is a integrated development environment (IDE) for R, created by Posit. It contains a set of tools designed to make writing R, python, javascript, and other data-related code easier.

  4. Download and install the latest version of Quarto for your operating system. Quarto is a command-line tool released by Posit that allows you to create documents using R or python, combining code, results, and written text.

The following steps may be necessary depending on which class you’re in. If you want to be safe, go ahead and complete these steps as well.

  1. Install git using the instructions here. Consult the troubleshooting guide if you have issues. If that fails, then seek help in office hours.

  2. Install LaTeX and rmarkdown:

    • Launch R, and type the following commands into the console:
    install.packages(c("tinytex", "knitr", "rmarkdown", "quarto"))
    library(tinytex)
    install_tinytex()
Your turn

Open RStudio on your computer and explore a bit.

  • Can you find the R console? Type in 2+2 to make sure the result is 4.
  • Run the following code in the R console:
install.packages(
  c("tidyverse", "rmarkdown", "knitr", "quarto")
)
  • Can you find the text editor?
    • Create a new quarto document (File -> New File -> Quarto Document).
    • Paste in the contents of this document.
    • Compile the document (Ctrl/Cmd + Shift + K) and use the Viewer pane to see the result.
    • If this all worked, you have RStudio, Quarto, R, and Python set up correctly on your machine.