Question: 1 . Consider the ` POPULATION ` data frame. a . Filter for all observations within the ` State ` variable with a value of

1. Consider the `POPULATION` data frame.
a. Filter for all observations within the `State` variable with a value of Indiana. Save this variable into an object called INDIANA. Print the first 10 rows.
b. Using the `INDIANA` data frame, use the pivot longer function to make the data set into long form. All of the year columns (`X2010`-`X2019`) should become one column while all the values should become another column. Choose appropriate names for the variable name. Save the long form data set into an object called `INDIANA.LONG`. Sort by the variable "POP". Print rows 75-83.
i.*Extra Point*- Remove the X at the beginning of each variable name within the pivot_longer function using extra arguments. (Adding extra functions to remove X will not grant the extra point.)
c. Turn the `INDIANA.LONG` data frame back into wide format using pivot_wider. Call this data frame INDIANA.WIDE. Print the ten largest populations only in 2015 in order from largest to smallest.
2. This question requires no code, but include written/typed responses to the following in your RMarkdown PDF output:
Dataset A has 70 unique ID rows of data and dataset B has 58 unique ID rows of data. Dataset C has 100 rows of data but only 72 unique IDs.
a. If you were to left join dataset A and B by ID, how many rows would the joined dataset have?
b. If you were to right join dataset A and B by ID, how many rows would the joined dataset have?
c. If you were to left join dataset A and C by ID, how many rows would the joined dataset have?
d. If you were to right join data B and C by ID, how many rows would hte joined dataset have?
e. Name the three requirements satisfied by tidy data.
3. Consider the DRINKS data set.
a. Filter to only contain data from the countries of USA, China, and Italy.
b. Remove the `total_litres_of_pure_alcohol` variable, and rename the following columns: `beer_servings` to `beer`,`spirit_servings` to `spirit`, and `wine_servings` to `wine`.
c. Converts the new subset from wide format to long format.
i. Convert the variables (column names) into a columns named `type` while the numerical values are a variable called `servings.`

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!