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()
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 ofheight_low_inches
andheight_high_inches
divided by12
, since there are12
inches in1 foot
popularity_change_15_to_16
is the difference in rank fromrank_2016
torank_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
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.