Problem set 1
Due by 11:59 PM on Monday, August 29, 2022
Task 1: Introduce yourself to R, RStudio, and the tidyverse
Go the the example page for this week, “Welcome to R, RStudio, and the tidyverse”, and work through the different primers and videos in the four parts of the page.
It seems like there’s a lot on the page, but they’re short and go fairly quickly (especially as you get the hang of the syntax). Also, I have no way of seeing what you do or what you get wrong or right, and that’s totally fine! If you get stuck and want to skip some (or if it gets too easy), go right ahead and skip them!
Task 2: Make an RStudio Project
Use either RStudio.cloud or RStudio on your computer (preferably RStudio on your computer! Follow these instructions to get started!) to create a new RStudio Project. Refer to the example page you read in Task 1 for instructions
Create a folder named “data” in the project folder you just made.
Download this CSV file and place it in that folder:
In RStudio, go to “File” > “New File…” > “R Markdown…” and click “OK” in the dialog without changing anything.
Delete all the placeholder text in that new file and replace it with this:
--- title: "Problem set 1" author: "Put your name here" output: html_document --- ```{r load-libraries-data, warning=FALSE, message=FALSE} library(tidyverse) cars <- read_csv("data/cars.csv") ``` # Learning R Tell me that you worked through the primers and videos and examples at the example page for this week: WRITE SOMETHING HERE LIKE "I did all the primers and had the time of my life!" or whatever. # My first plots Insert a chunk below and use it to create a scatterplot (hint: `geom_point()`) with diplacement (`displ`) on the x-axis, city MPG (`cty`) on the y-axis, and with the points colored by drive (`drv`). PUT CHUNK HERE Insert a chunk below and use it to create a histogram (hint: `geom_histogram()`) with highway MPG (`hwy`) on the x-axis. Do not include anything on the y-axis (`geom_histogram()` will do that automatically for you). Choose an appropriate bin width. If you're brave, facet by drive (`drv`). PUT CHUNK HERE # My first data manipulation Insert a chunk below and use it to calculate the average city MPG (`cty`) by class of car (`class`). This won't be a plot---it'll be a table. Hint: use a combination of `group_by()` and `summarize()`. PUT CHUNK HERE
Save the R Markdown file with some sort of name (without any spaces!)
Your project folder should look something like this:
Task 3: Work with R
- Remove the text that says “PUT CHUNK HERE” and insert a new R code chunk. Either type ctrl + alt + i on Windows, or ⌘ + ⌥ + i on macOS, or use the “Insert Chunk” menu:
Follow the instructions for the three chunks of code.
Knit your document as a Word file (or PDF if you’re brave and installed LaTeX). Use the “Knit” menu:
Upload the knitted document to iCollege.
🎉 Party! 🎉