nc_county <- read_csv("data/nc-county.csv")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:
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:
-
county: Name of county; -
land_area_m2: Land area of county in meters-squared, based on the 2020 census; -
land_area_mi2: Land area of county in miles-squared, based on the 2020 census; -
pop_2020: Population of county, based on the 2020 Census; -
pop_dens_2020: Population density calculated as population (pop_2020) divided by land area in miles-squared (people per mile-squared); -
county_type: Peer county type classification based on population characteristics, socioeconomic status, and geographic features used for grouping counties with similar demographic, social, and economic characteristics, allowing them to be compared and benchmarked against one another; -
median_hh_income: Median household income; -
p_foreign_born: Percentage of population that is foreign-born; -
p_child_poverty: Percentage of children living in poverty; -
p_single_parent_hh: Percentage of households with children that are single-parent households; -
p_broadband: Percentage of households with broadband internet access; -
p_home_ownership: Percentage of households that are owner-occupied; -
p_family_sustaining_wage: Percentage of adults that earn a family-sustaining wage – typically a wage that covers essential costs like housing, food, childcare, transportation, and healthcare for a family’s basic needs within a specific geographic area; -
p_edu_lths: Percentage of 25-44-year-olds with less than a high school diploma; -
p_edu_hsged: Percentage of 25-44-year-olds with a high school diploma or equivalent; -
p_edu_scnd: Percentage of 25-44-year-olds with some college or an associate degree; -
p_edu_ndc: Percentage of 25-44-year-olds with non-degree credentials – certifications, licenses, or other credentials that demonstrate specific skills or knowledge but do not confer a formal academic degree; -
p_edu_assoc: Percentage of 25-44-year-olds with an associate degree; -
p_edu_ba: Percentage of 25-44-year-olds with a bachelor’s degree; -
p_edu_mapl: Percentage of 25-44-year-olds with a master’s, professional, or doctoral degree; -
p_edu_hs_grad_rate: High school graduation rate; -
p_edu_chronic_absent_rate: Chronic absenteeism rate.
Setup
- Log-in to your container;
- Double-check that you have the
sta101-f26-filesproject loaded in the upper-right corner of RStudio (this should always be true); - 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
labfolder of your Files; - 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 theauthorsso it lists yourself and your teammates.
Task 1
- Make a well-labeled histogram of the
pop_2020variable; - Compute the mean and the standard deviation of the county populations.
Task 2
- Make a well-labeled boxplot of the
pop_2020variable; - Compute the median and the inner-quartile range (IQR) of the county populations;
- 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:
- Hit the blue Render button to generate your final PDF;
- 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;
- Download the PDF from your container;
- Upload it to Gradescope;
- Don’t forget to mark your pages.
