Photo by Clark Van Der Beken on Unsplash
In this assignment we’ll look at traffic accidents in Edinburgh. The data are made available online by the UK Government. It covers all recorded accidents in Edinburgh in 2018 and some of the variables were modified for the purposes of this assignment.
Open the project for this assignment in the course Posit Cloud workspace.
Open the R Markdown document hw-03.Rmd and render it before making any changes.
Make sure it renders without errors.
This first render is a useful check that the project, packages, data, and files are all working correctly.
Before we introduce the data, let’s warm up with a simple exercise.
🧶 ✅ Throughout this assignment, remember to render your document regularly. After rendering, check the output to make sure your code, figures, and written responses appear as you expect.
We’ll use the tidyverse package for much of the data wrangling and visualization.
You can load them by running the following:
If one of these packages is not installed, run the appropriate install.packages() command in your Console.
For example:
You only need to install a package once.
Do not put install.packages() commands in the code you render for your assignment.
Our included with the assignment and can be loaded directly using:
You can also find this information here.
Hint: The Markdown Quick Reference sheet has an example of inline R code that might be helpful. You can access it from the Help menu in RStudio. It is also referenced in this section of the R Markdown Cookbook.
View(accidents) in your Console to view the data in the data viewer. What does each row in the dataset represent?🧶 ✅ Write your answers under Exercises 1 and 2, then render the document. Check that your written responses appear correctly and that the inline R code in Exercise 1 displays a number rather than code.
In your answer, don’t forget to label your R chunk as well (where it says label-me-1).
Your label should be short, informative, shouldn’t include spaces, and shouldn’t repeat a previous label.
🧶 ✅ Complete the code for Exercise 3 and write your interpretation underneath it. Render the document and check that the figure appears correctly, your chunk has a unique label, and your written response describes the patterns you see in context.
You can choose any variables and any type of visualization you like, but it must include at least three variables.
For example, a scatterplot of x versus y isn’t enough, but if the points are colored by a third variable, that would meet the requirement.
In your answer, don’t forget to label your R chunk as well (where it says label-me-2).
🧶 ✅ Complete your visualization and written interpretation for Exercise 4. Then render your document one final time. Read through the rendered document from beginning to end and make sure all code runs, both figures appear correctly, your chunk labels are unique, and every exercise marked with ✏️ includes a written response before you submit your work.