---
title: "Lab 1.1 - Hello, RStudio!"
output:
  html_document:
    code_download: true
---

```{r include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

This lab exercise introduces [R](https://www.r-project.org/) and [Posit/RStudio](https://www.posit.co/) using data from the [Seattle pet registration website](https://data.seattle.gov/Community/Seattle-Pet-Licenses/jguv-t9rb).
We will use Posit&rsquo;s RStudio Integrated Development Environment (IDE) to manage data, analysis, and scripting.

## The Dataset

Go to dataset website (linked above) and do the following:

1. Review the description of the dataset and, in particular, study the *data dictionary* (i.e., "Columns in this Dataset"), which specifies the data fields stored for each pet registration entry.

2. Download (i.e., "Export") the dataset to your local machine and load it into MS Excel. Check that the data matches the website's description. Verify that the fields listed in the data dictionary match, and check many entries there are.

This dataset is a well-formatted, comma-separated-values (CSV) file. If you have problems downloading the file, you can access [this local copy](data/Seattle_Pet_Licenses.csv) (data from October 7, 2021).

## RStudio

RStudio integrates file editing and R programming. Log in to the course Posit server (see the main course page for the link) and do the following: 

1. *Console* --- The Console pane (on the lower left) provides an R interpreter into which you can enter R commands. Try typing the following commands:

    a. `1 + 1` --- This *arithmetic expression*, and others like it, should evaluate properly.
    
    b. `library(tidyverse)` --- This *function call* loads the Tidyverse *library*, which provides basic data wrangling and analysis functions.

2. *Files* --- The Files pane (on the lower right) provides a file browser. For both this lab and future labs, do the following:

    a. Create a "New Folder" for this course with an appropriate name (e.g., `info601`) and then, inside that folder, create a sub-folder named `lab01` for this lab. Use this folder (e.g., `info601/lab01`) to store all your lab 1 files and to keep them separate from the files for your other lab and homework assignments.

    b. For this lab (and others), you'll also need data files, so create a `data` sub-folder (e.g., `info601/lab01/data`) and "upload" the pet registration CSV file linked from the Moodle course into that folder.
    
3. *Editor* --- The Editor pane (which will appear on the upper left) provides a way to view and modify files. Do the following:

    a. Click on the CSV file in the File pane and select "View File". This will open the raw CSV file in the editor pane.

    b. Be sure that you can answer these questions:
    
        i. What data is stored in the first line of the CSV file?
  
        ii. How do the other lines of the file compare with the way they are presented in Excel?

        iii. Why there are no spaces around the commas?

4. *Environment* --- The Environment pane (which will appear on the upper right) provides a view of the R objects currently being stored by RStudio. Do the following:

    a. Click on the CSV file again in the File pane, but this time select "Import Dataset". This will open a formatted version of CSV file in the Editor pane and add the registry dataset to the Environment Pane. Verify that this happens.
    
    b. Create a new variable by typing `x <- 1` in the Console pane. Verify that this adds a new object named `x` to the Environment pane.

There's nothing to turn in for this exercise.
