Lab 1

Due: end-of-lab Friday September 4

In this lab you will practice the basics of data visualization (ggplot) and data summarization (dplyr and |>) using a dataset on counties in North Carolina. The dataset contains information on North Carolina counties retrieved from the 2020 Census as well as from myFutureNC Dashboard maintained by Carolina Demography at the University of North Carolina at Chapel Hill.

This dataset is stored in the file nc-county.csv, which you can read into R with the following code:

nc_county <- read_csv("data/nc-county.csv")

This will read the CSV (comma separated values) file from the data folder and store the dataset as a data frame called nc_county in R.

The variables in the dataset and their descriptions are as follows:

Setup

  1. Log-in to your container;
  2. Double-check that you have the sta101-f26-files project loaded in the upper-right corner of RStudio (this should always be true);
  3. Go to the “Git” tab in the upper-right panel of RStudio and click the Pull button (arrow pointing down). Now the new assignment template and dataset should appear in the lab folder of your Files;
  4. At the top of the new .qmd, in between ---, you have the settings for the document (the so-called YAML, but don’t worry about that). Modify the authors so it lists yourself and your teammates.

Task 1

  1. Make a well-labeled histogram of the pop_2020 variable;
  2. Compute the mean and the standard deviation of the county populations.

Task 2

  1. Make a well-labeled boxplot of the pop_2020 variable;
  2. Compute the median and the inner-quartile range (IQR) of the county populations;
  3. Referring to your plots and summaries, describe the distribution (center, spread, shape) of the county populations.

Task 3

Make a scatter plot of population density (pop_dens_2020 on the y-axis) vs. land area in miles-squared (land_area_mi2 on the x-axis). Make sure to set an informative title and axis labels for your plot.

Submission

You collaborated with your team, but now everyone submits individually:

  1. Hit the blue Render button to generate your final PDF;
  2. Give your work a final look over to double-check a few things:
    • that your code is stylish;
    • that none of your code or pictures runs off the page. We cannot grade what we cannot read;
    • that all of your plots are well-labeled and human-readable. In other words “Flipper length (mm)” instead of flipper_length_mm;
    • If your work is lacking on any of these items, fix them and re-render as needed;
  3. Download the PDF from your container;
  4. Upload it to Gradescope;
  5. Don’t forget to mark your pages.