AE 09: Age gaps + sales + import

Application exercise

Getting started

Packages

We will use the following two packages in this application exercise.

  • tidyverse: For data import, wrangling, and visualization.
  • readxl: For importing data from Excel.
# add code here

Part 1: Hollywood relationships

Load the data from age-gaps.csv in your data and assign it to age_gaps. Confirm that this new object appears in your Environment tab. Click on the name of the object in your Environment tab to pop open the data in the data viewer.

# add code here

Create a subset of the data frame for heterosexual relationships on screen.

# add code here

Split the data for heterosexual relationships into three – where woman is older, where man is older, where they are the same age. Save these subsets as two appropriately named data frames. Remember: Use concise and evocative names. Confirm that these new objects appear in your Environment tab and that the sum of the number of observations in the two new data frames add to the number of observations in the original data frame.

# add code here

Write out the three new datasets you created into the data folder:

# add code here

Part 2: Sales

Sales data are stored in an Excel file that looks like the following:

Read in the Excel file called sales.xlsx from the data folder such that it looks like the following.

# add code here

Stretch goal: Manipulate the sales data such such that it looks like the following.

# add code here

Why should we bother with writing code for reading the data in by skipping columns and assigning variable names as well as cleaning it up in multiple steps instead of opening the Excel file and editing the data in there to prepare it for a clean import?

Add response here.