---
title: 'Lab 4: Introduction to Data Wrangling'
format:
  html:
    embed-resources: true
knitr:
  opts_chunk:
    message: false
---

###### Question 1
Insert a new code chunk in your Quarto document. In this code chunk, write code that will:

1. Load the `tidyverse` package
2. Import the `acs12` data set from the `openintro` package, and store a copy of it as an object named `acs_df` in our environment.

###### Question 2
Based on the output from the `glimpse()` function, answer the following questions:

1. How many variables directly related to employment are measured in these data?
2. Is level of education measured as a numeric or categorical variable?

###### Question 3

Insert a new code chunk into your Quarto document. Then, copy the template code below into this code chunk:

Modify this template so that the `select()` function keeps only the variables `married`, `race`, and `edu`.

###### Question 4
Insert a new code chunk into your Quarto document, and write code that will

1. Select the `employment`, `time_to_work`, and `hrs_work` variables from the `acs_df` data set.
2. Store this new subset of of the ACS data in an object named `acs_employment`.
3. Prints out a "glimpse" of the `acs_employment` data.

###### Question 5
Insert a new code chunk into your Quarto document, and copy the template code below into your new code chunk.

Modify this template so that the `filter()` function only keeps observations where `time_to_work` is greater than or equal to 35 minutes **and** `income` is strictly greater than fifty thousand dollars (\$50000).

###### Question 6
Use the `mutate()` command to generate a new variable in the `subset_df` data frame that measures age in months instead of years.

###### Question 7
Insert a new code chunk into your Quarto document, and copy the template code below into your new code chunk.

Modify this code template so that the `arrange()` function sorts the `subset_df` data frame by the `hrs_work` variable.

###### Question 8
Insert a new code chunk into your Quarto document, and write code that will arrange the `subset_df` data frame by `time_to_work` in *descending* order.

###### Question 9
Insert a new code chunk into your Quarto document, and copy the template code below into your new code chunk.

Modify this template so that the `select()` function keeps just the variables `hrs_work`, `income`, and `married`, and the `filter()` function keeps just the observations where `income` is less than \$ 30,000.

###### Question 10
Insert a new code chunk into your Quarto document, and write a data wrangling "pipeline" that will

- generate a new variable named `income_1000` that measures income in thousands of dollars (instead of dollars)
- sort the data in ascending order of hours worked
- select just the hours worked and income in thousands of dollars variables

