Week 1 - Set up SPSS & R with RStudio

updated Jan 24 2024

1. SPSS installation/access

NEW! - Rutgers has added an alternative method to connect to a Virtual Computing Session. This alternative method may allow you to save files directly to your computer (we have not tested it so please explore on your own if you want to use it) - see here for instructions.

screenshot of a Virtual Computing Session Virtual Computing screenshot

2. Install R and RStudio on your computer

R is a statistical programming language. RStudio is a development environment built to make it easier to run, view, and document with the R language. R and Rstudio are open-source, so you can install them on your own.

3. Start RStudio and install essential R packages

4. Set up your workflow for this week's lab activity

This video (linked in the Syllabus also) describes the workflow that we will use in class. These are the basic steps in the workflow:
1. Create a folder containing an RStudio project (*.Rproj file) for the lab activity each week. This week, make a folder called "intro-essentials" and then use File -> New Project -> Existing Folder to create an R project file in the "intro-essentials" folder. Open the project in your current session.
2. Inside the folder you made for the project, create new folders called "data", "r_docs", and "images". You can create the folders through the Files tab in the lower right RStudio Pane, or as you normally would in Windows or MacOS.
3. Create an R Markdown file called "lab-notes-intro" and save it in "r_docs" folder. Use File ->New File -> R Markdown... then Save (on the RStudio menu). The markdown file will open in the top left RStudio pane - this is where you will write your R code and where you will take notes. When you reach a point where you want to share the document you can use the Knit option to generate a report containing your code, notes, and visualizations.
4. Delete the template text starting from "## R Markdown" down to the end of the file.
5. Write your code inside code "chunks", and run chunks in order when writing/testing code. When you want to generate a report (e.g., an html file that you can share), use the Knit button.
- the start of a chunk is designated by a line that starts with 3 backticks ` followed by {r chunk-name}. The end of a chunk is designated by a line with 3 backticks.
- in the "setup" code chunk, add this line to set the working directory (see here for explanation):
knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())
6. Write your notes above or below code chunks. Characters like # and * are used for markdown-style formatting of the report as described in this pdf.

When you have set up your project, your RStudio environment should look something like this:
Rstudio project

5. Load the first "discovr" tutorial

Go to the Tutorial Pane (top right) and click "start tutorial" for the "discovr: key concepts in R (discovr_01)" tutorial. it will take a minute or two to load - use the "pop-out" button popout icon to open the tutorial in a larger view.