Chapter 2 Installation

To participate in PLSC 31101, you will need access to the software described below.

Once you’ve installed all of the software below, test your installation by following the instructions at the bottom on this page.

2.1 R

R is a programming language that is especially powerful for data exploration, visualization, and statistical analysis.

To download R, go to CRAN (the Comprehensive R Archive Network).

A new major version of R comes out once a year, and there are 2-3 minor releases each year. It’s a good idea to update regularly. Upgrading can be a bit of a hassle, especially for major versions, which require you to reinstall all your packages, but putting it off only makes it worse.

2.2 R Studio

To interact with R, we use RStudio. Please install the latest desktop version of RStudio IDE. We will not support RStudio cloud.

2.3 R Packages

You’ll also need to install some R packages. An R package is a collection of functions, data, and documentation that extends the capabilities of base R. Using packages is key to the successful use of R.

Many of the packages that you will learn in this class are part of the so-called tidyverse. The packages in the tidyverse share a common philosophy of data and R programming, and are designed to work together naturally.

You can install the complete tidyverse with a single line of code in R Studio:

install.packages("tidyverse")

On your own computer, type that line of code in the RStudio console, and then press enter to run it. R will download the packages from CRAN and install them on to your computer. If you have problems installing, make sure that you are connected to the internet, and that https://cloud.r-project.org/ isn’t blocked by your firewall or proxy.

We will also be requiring a few other important packages. Run the following line of code to download all of them at once:

install.packages("rmarkdown", "knitr", "gapminder", 
                 "stargazer", "rtweet", "kableExtra",
                 "nycflights13", "devtools", "tm", "wordcloud",
                 "matrixStats", "SnowballC", "tidytext",
                 "textdata", "stm")

2.4 LaTex

In order to knit rmarkdown files to pdf files, you need to install some version of Latex. For students who have not installed LaTeX before, we recommend that you install TinyTeX (https://yihui.name/tinytex/).

Open RStudio and type these lines into the command-line console:

install.packages("tinytex")
tinytex::install_tinytex() 

2.5 The Bash Shell

Bash is a commonly-used shell that gives you the power to do simple tasks more quickly.

Windows

Install Git for Windows by downloading and running the installer. This will provide you with both Git and Bash in the Git Bash program. NOTE: on the ~6th step of installation, you will need to select the option “Use Windows’ default console window” rather than the default of “Use MinTTY” in order for nano to work correctly.

After the installer does its thing, it leaves the window open, so that you can play with the “Git Bash”.

Chances are that you want to have an easy way to restart that Git Bash. You can install shortcuts in the start menu, on the desktop or in the QuickStart bar by calling the script /share/msysGit/add-shortcut.tcl (call it without parameters to see a short help text).

Mac OS X

The default shell in all versions of Mac OS X is bash, so no need to install anything. You access bash from the Terminal (found in /Applications/Utilities). You may want to keep Terminal in your dock for this class.

Linux

The default shell is usually Bash, but if your machine is set up differently you can run it by opening a terminal and typing bash. There is no need to install anything.

2.6 Git

Git is a version control system that lets you track who made changes to what when and has options for easily updating a shared or public version of your code on github.com. You will need a supported web browser (current versions of Chrome, Firefox or Safari, or Internet Explorer version 9 or above).

Windows

Git should be installed on your computer as part of your Bash install (described above).

Mac OS X

For OS X 10.9 and higher, install Git for Mac by downloading and running the most recent “mavericks” installer from this list. After installing Git, there will not be anything in your /Applications folder, as Git is a command line program. For older versions of OS X (10.5-10.8) use the most recent available installer labelled “snow-leopard” available here.

Linux

If Git is not already available on your machine you can try to install it via your distro’s package manager. For Debian/Ubuntu run sudo apt-get install git and for Fedora run sudo yum install git.

2.7 Other helpful tools

While not required, I recommend you install the following tools:

  1. Google Chrome is an up-to-date web browser.

  2. Sublime Text is a free, advanced text editor.

2.8 Testing your installation

If you have trouble with installation, please come to the Installfest on Wed Oct 2, 10-12 in Pick 411.

Open a command line window (‘terminal’ or, on windows, ‘git bash’), and enter the following commands (without the $ sign):

$ R --version
$ git --version

If everything has been installed correctly, those commands should print output version information.

NB: If you’re using git bash, the R --version command may not work. In this case, just make sure you can open up RStudio.

Software Carpentry maintains a list of common issues that occur during installation may be useful for our class here: Configuration Problems and Solutions wiki page.

Credit: Thanks to Software Carpentry for providing installation guidelines.