Assumptions & Ground Rules

(Note: This document was created as an R Markdown file. You will learn about R Markdown files later. First, I want to familiarize you with the RStudio interface.)

The purpose of this first assignment is to demonstrate that you have downloaded the “base R” and “RStudio” statistical programs and can open a SPSS datafile in RStudio.

For all assignments in this class, you must have access to a computer and should also use a cloud-based file system. (e.g. OneDrive, Dropbox). Working from cloud storage is essential - and not just for this class! By saving and backing up using cloud storage, you will be able to access your saved files from any computer, you will still have access to your saved files if your computer were to unfortunately stop working, and you can easily share files and folders with collaborators.

Thus, for this and all future assignments, I will assume you are working on your own computer, are downloading base R and RStudio (free open source) programs on your own computer, and are working from your cloud storage via your computer’s file explorer.

Also, for this and all future assignments, you MUST type all commands in by hand. Do not copy & paste except for troubleshooting purposes (i.e., if you cannot figure out what you mistyped). Trust me - you will learn better from typing.

  • Early on, you may have a lot of trouble getting your code to run due to minor typos. This is normal.
  • Remember, you are learning to read and write a new (coding) language. As with learning any new languages, we learn from practice - and from correcting our mistakes.

Part 1 (Assignment 1.1)

Goal: Create new LastName_P680_work folder in your OneDrive cloud storage, then download datasets and save to your new folder (i.e., “work” indicates this is the cloud folder within which you will do most of your work for the course).

(Note: When following instructions, always substitute “LastName” for your own last name! Also, substitute YEAR_MO_DY for the actual date. E.g., Brauer_P680_Assign1_2021_08_23)

  1. On your computer, navigate to your OneDrive folder, then create a new folder called “LastName_P680_work” in a location that is easy to access (e.g., in the root OneDrive folder).
  2. Create two new folders in your P680_work folder: a “Datasets” folder (LastName_P680_work > Datasets) and an “Assignments” folder (LastName_P680_work > Datasets)
  3. Visit the Week 2 Module, below the “R Assignment 1: Introduction to R & RStudio” entry, on the class Canvas site to download the SPSS data file “MonitoringtheFuture2013grade10_0.sav.” This was downloaded from the companion website for Bachman & Paternoster’s Statistics for Criminology & Criminal Justice, 4th Ed.
  4. Save the dataset in the new “LastName_P680_work > Datasets” folder you made in Part 2.
  5. Open a Word document. At the top, put your name, date, course information (F21-P680; Dr. Brauer), and heading (Assignment 1). Then, create a subheading for Part 1 (e.g., Assignment 1.1).
  6. Take a screenshot (#1) of your new LastName_P680_work > Datasets folder with all six datasets downloaded in it and past into a Word document.
    • PC: ctrl + prt sc then ctrl + P into a Word document underneath the subheading for Part 1. Or, in the search bar type in “snipping tool” and use the tool to take a snapshot of your Datasets folder.
    • Mac: Command + shift + 3, this saves on your desktop. Then, paste into the Word document under the Part 1 subheading.
  7. Save the Word document with your screenshot to your “LastName_P680_work > Assignments” folder. Name the file: LastName_P680_Assign1_YEAR_MO_DY (e.g., I would name my assignment: Brauer_P680_Assign1_2021_08_23).
    Completing Assignment 1.1

    Completing Assignment 1.1

Part 2 (Assignment 1.2)

Goal: Download R & RStudio; set Global Options; install “haven” and “here” packages.

In this section, you will begin by downloading and installing two programs on your computer: base R and RStudio.The first program, R, is simultaneously a computer coding language and a statistical software program. The second, RStudio, is an integrated development environment (IDE) that provides a more user-friendly interface for working with the R program. Throughout this course, you will learn to write and submit R code in RStudio to run statistical commands in the R program. After installing R & RStudio, you will run some simple commands to familiarize yourself with the basic features of the program and install two R packages.

  1. Follow the instructions at the link below to install the latest versions of R and RStudio on your personal Windows or Mac computer:
  2. Visit Antoine Soetewey’s blog (AS blog) entry at the link below, read the section titled “Main Components of RStudio,” and follow along in RStudio on your computer:
  3. At the top of RStudio, navigate to “Tools” then click “Global Options” and change the following settings:
    • Uncheck “Restore .RData into workspace at startup”
    • Change “Save workspace to .RData on exit” to “Never”
    • Uncheck both boxes under “History”
    • Our goal is to write and save standalone reproducible code that can be run at any time by anyone with the file and associated file structure. In my experience, these options aid in pursuit of that goal while minimizing headaches when collaborating with others using shared drives. For additional information, see Section 4.5 in Nicholas Tierney’s R Markdown for Scientists. Because of this, unlike in the picture below, I also remove the check from “Restore most recently opened project at startup” and “Restore previously open source documents at startup.” While I recommend doing so as well, you can decide whether or not it is useful to you.