-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprework.Rmd
62 lines (37 loc) · 2.53 KB
/
prework.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
title: "Pre-work"
output:
distill::distill_article:
toc: true
toc_float: true
toc_depth: 4
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
We'll be going over Functions, Lists, and Loops in this session. Some familiarity with using R and opening RStudio is helpful if you are actively participating, otherwise all are welcome to watch and learn.
R and the RStudio IDE are required. See the first module on [R Basics](https://psrc.github.io/r-basics-I/00-index.html) for guidance.
# Session Files on Local Drive
1. Clone the repo [https://github.com/psrc/intro-code-org](https://github.com/psrc/intro-code-org) onto your local drive.
2. Download the CHAS zip file of the `2015-2019 ACS 5-year average data` for `Census counties` from [here](https://www.huduser.gov/portal/datasets/cp.html#data_2006-2019).
- Extract the zipfile in the `data` sub-directory of the cloned repo.
- All data files will be found in `data/050`.
![](slides/images/chas-download.png)
Make sure that the repo and other files for the session are **on your local drive**. If they are on PSRC's network, you may experience extreme sluggishness when using a `.Rproj` file.
## Open .Rproj
In the RStudio IDE, open the `.Rproj` file in the repo. Project files will automatically set our working directory--in this case, the root of the directory. No need for `setwd()` and dealing with file paths!
After opening the `.Rproj` file, you'll see some changes to your IDE. Your console and `Files` pane will reflect the new working directory, and the project name is listed in the top right corner.
To close out of the project, click the project name at the top right corner and select `Close Project`. On the day of the session, you can access the dropdown in that area of the IDE and select `intro-code-org`.
# Install
If the following packages have not been installed, install the following by running the following code snippet in the console of your RStudio IDE. Ignore any warnings regarding `Rtools` and if you are asked to install from sources which needs compilation, click 'No'.
<aside>
Some may have already been installed from previous modules. You can adapt the code snippet accordingly.
</aside>
```{r eval=FALSE, echo=TRUE}
install.packages(c('tidyverse', 'here'))
```
# Test
Test to make sure you can read csvs from the CHAS dataset that was downloaded. Adjust the line below according to how you've stored your files in the `data` sub-directory.
```{r eval=FALSE, echo=TRUE}
file_01 <- read_csv(here('data', '050', 'Table9.csv'))
```