Lecture 03b Assignment
Unit A · Chapter 03
Instructions
Create a new Quarto document (HTML format), clear out the boilerplate code/text, and use this document to store your answers to each of the three questions below. Be sure to enable embed-resources using the header below. Replace the header at the top of your new document with this one; embed-resources: true puts everything into the single HTML file you submit. If your answer involves writing text, then use markdown to write 2–4 sentences per part, or more if a part asks several things or names its own length; if your answer involves running code, then use one or more code chunks. For questions that ask you to fix code, correct any errors (while achieving the stated goal) and include only the working code in your document.
---
title: "Lecture 03b Assignment"
author: "Your Name"
format: html
embed-resources: true
---Please clearly mark which part of your document is answering which question (e.g., using markdown headings) and remove any “scratch work” or failed attempts from your document before submitting it. Finally, note that many essay-style questions will require you to read between the lines and use your imagination (as opposed to just looking up the answer in the lecture).
Question 1 (Data Frames)
| planet | moons | kind |
|---|---|---|
| Earth | 1 | rocky |
| Mars | 2 | rocky |
| Jupiter | 97 | gas giant |
| Saturn | 274 | gas giant |
Create three vectors from the columns of the table above and combine them into a tibble named
planets. Print the tibble.Look at the short type abbreviation printed under each column name. Report what type R gave each of the three columns, and explain in a sentence or two why it is useful that a tibble keeps track of the type of each column.
Question 2 (Data Files)
Download the
factbook.csvfile and read it into R as a tibble. When you read it in, tell R that any cell containing an asterisk (*) is actually missing.Use a function from the easystats package to describe the distribution of all continuous variables in this tibble. Which variables contain missing values, and what is the mean of the
maternal_mortalityvariable?
Question 3 (Data Exploration)
Read the “factbook.csv” file into R again for this question (remembering to treat asterisks as missing) so that it can be answered on its own.
Use
qplot()to make a histogram of thebirth_ratevariable. Which values are the most common for this variable?Use
qplot()to visualize the covariation (how the two variables change together) of thelife_expandnet_migration_ratevariables. Do any points seem unusual on one or both variables?
✅ Done! Please save and then render your document to an HTML file. Check it over to make sure it is complete (and rendered properly) and then submit it as directed by your instructor. Note that, if any of your code chunks has an error in it, the HTML file will not render properly (this is why removing scratch work is important). If you receive an error message upon clicking “Render” about a missing file, this actually means that there is an error in one of your chunks.