A R and Rstudio
R is a free professional statistical software that is available for use on windows, mac and linux computers. R is a popular tool for researchers from many fields so acquiring basic R skills from our stats classes will be beneficial for this course and career plans!
RStudio is a free software that provides a user-friendly interface with R. We will be running R through RStudio in our stats classes.
R can be more challenging for a brand new user than other software (like Excel, SPSS, etc) because analyzes are done using written commands rather than using a drop down (point-and-click) menu. But R is very powerful because of the huge variety of statistical methods that it supports (due to the addition of free user contributed packages) and the user’s ability to customize their experience (graphics, new functions, data manipulation, etc). Because R is based on written commands that can be recorded in a variety of ways, it is easy for a user to reproduce, re-do or continue analyzes that were started at a different point in time. This is much harder to do when you are using a bunch of drop-down menu commands to run your analysis! We will emphasize reproducibility in this course by using R Markdown scripts (Section D) to complete our analyzes.
A.1 Running Rstudio
-
Browser: You can access an online version of Rstudio from maize.mathcs.carleton.edu. If you are new to using Rstudio, I encourage you to use maize rather than installing R/Rstudio on your computer. You can access maize from anywhere on campus using Eduroam wireless if on a laptop, but from off campus you will first need to turn on Carleton’s VPN prior to logging in. Please install this software!
-
Why use maize? Any work you create (R scripts, Markdown, pdf, or word docs) are saved on your account located on this server (file path /Accounts/username). Maize also has most R packages that we use in our classes preinstalled so you don’t need to install them before using them.
- Getting files off of maize: If you want to download a file from this account, check the button next to the file in the Files pane (lower right panel). (Don’t use the “File” dropdown menu for this!) Then select the More > Export drop down menu from this pane and click Download. The file should be located in the default download location for your browser.
- Getting files onto maize: I will give you many files (usually .Rmd) in this class that you will want to upload, or add, to your maize Rstudio account. To do this, download the file to your computer to a place you know about like Downloads or Desktop. Then in your Stat230 project folder on maize, click the upload button from the Files pane (lower right panel). (Don’t use the “File” dropdown menu for this!) Click Choose file and navigate to the location of the file on your computer. Click Open and Ok to upload this file to your maize account.
-
Why use maize? Any work you create (R scripts, Markdown, pdf, or word docs) are saved on your account located on this server (file path /Accounts/username). Maize also has most R packages that we use in our classes preinstalled so you don’t need to install them before using them.
- Personal computer: You can download R (Section A.2) and Rstudio (Section A.3) software onto your personal computer. You then open Rstudio to start an R session. You will need install certain R packages that we used in our class that aren’t part of the default package installation. See Section A.4.
A.3 Installing Rstudio
Follow the link below and download the free RStudio Desktop Open Source Edition.
- Windows or Mac: http://www.rstudio.com/ide/download/
A.4 Installing R packages
R packages provided added analysis tools that R users contribute to the R community. The default R installation only provides us with a fraction of the available packages. The most straightforward way to install a needed package in Rstudio is to click the Packages tab in the lower right pane. Click the Install button and start typing the package name into Packages field, then click Install to add the package to your available package library. You should only need to install a package once.
Alternatively, you can install a package by typing an install.packages
command into the Console window. For example, the following command installs the R data package Sleuth3
for The Statistical Sleuth textbook:
> install.packages("Sleuth3")