Learn

With an understanding of how to manipulate data frames with dplyr, you are well on your way to becoming a data analysis expert! In this lesson you learned how to:

  • add new columns to a data frame using mutate()
  • add new columns to a data frame and drop existing columns using transmute()
  • change the column names of a data frame using rename()

Cute puppy that loves dplyr

Instructions

1.

Add the two columns defined below to dogs while dropping all existing columns from the data frame:

  • height_average_feet is the average of height_low_inches and height_high_inches divided by 12, since there are 12 inches in 1 foot
  • popularity_change_15_to_16 is the difference in rank from rank_2016 to rank_2015

Save the result to dogs, and inspect dogs using head().

2.

Add breed back into the dogs data frame by adding the following line of code as the first argument of the call to transmute():

breed = breed

This will keep the breed column from being dropped in the transmuted data frame!

3.

Arrange the rows of dogs by descending popularity change from 2015 to 2016. Save the result to dogs.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?