dplyr functions.lab03.Rmd to open the template R Markdown file.All plots should follow best visualization practices; plots should include:
Don’t forget to label your R chunk as well. Your label should be short, informative, shouldn’t include spaces, and shouldn’t repeat a previous label.
We need the tidyverse and dsbox for this lab. If you don’t have dsbox already installed, please run commented lines only once.
library(tidyverse)
theme_set(theme_bw())
# install.packages("devtools")
# devtools::install_github("rstudio-education/dsbox")
library(dsbox) # for data
library(sf)The data set ncbikecrash is available in the dsbox package and contains all NC bike crash data from 2007 - 2014. Check the documentation of the data by typing ?ncbikecrash in your console.
geom_line(), geom_point(), and scale_x_continuous(breaks = 2007:2014). Please describe what you observe.🧶 ✅ ⬆️ Knit, commit, and push your final changes to GitHub with a meaningful commit message.
crash_hour and hit_run.
crash_hour at each level of hit_run using faceting. What do you learn about the relationship from this plot?🧶 ✅ ⬆️ Knit, commit, and push your final changes to GitHub with a meaningful commit message.
ifelse([condition], [value1], [value2]) function assigns [value1] if [condition] holds and [value2] otherwise.ncbikecrash <- ncbikecrash %>%
mutate(week = ifelse(crash_day %in% c("Saturday", "Sunday"),
"Weekend", "Weekday"))🧶 ✅ ⬆️ Knit, commit, and push your final changes to GitHub with a meaningful commit message.
Now we will play with spatial data. Use the code below to load the NC shapefile downloaded from NC OneMap.
nc_counties <- st_read("data/nc_counties.shp", quiet = TRUE) ncbikecrash and nc_counties.
nc_counties.ncbikecrash_sf that contains all accidents in ncbikecrash and associated geometry features. The resulting data set should be a simple feature, too.scale_fill_gradient() to fill counties with a color gradient. Use informative colors for low and high number of accidents.
ncbikecrash.nc_counties and ncbikecrash.🧶 ✅ ⬆️ Knit, commit, and push your final changes to GitHub with a meaningful commit message.
Once you are fully satisfied with your lab, Knit to .pdf to create a PDF document.
Follow the instructions in previous labs to submit your PDF to Gradescope.
Be sure to identify which problems are on each page using Gradescope.
Once you are finished with the lab, you will submit the PDF document produced from your final knit, commit, and push to Gradescope.
Before you wrap up the assignment, make sure all documents are updated on your GitHub repo. We will be checking these to make sure you have been practicing how to commit and push changes. Remember – you must turn in a .pdf file to the Gradescope page by the submission deadline to be considered “on time”.
To submit your assignment:
| Component | Points |
|---|---|
| Ex 1 | 7 |
| Ex 2 | 9 |
| Ex 3 | 10 |
| Ex 4 | 6 |
| Ex 5 | 7 |
| Ex 6 | 4 |
| Workflow & formatting | 7 |
Grading notes: