FAQ: Modifying Data Frames in R - Rename Columns

This community-built FAQ covers the “Rename Columns” exercise from the lesson “Modifying Data Frames in R”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn R

FAQs on the exercise Rename Columns

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hello–I’m having a problem with this–

Can anyone see where I’m wrong? I am getting a “cant rename columns that don’t exist” error–I’ve checked spelling and such and nothing seems to be wrong?

dogs %>%

rename(avg_height = avg_height_inches,

avg_weight = avg_weight_lbs,

rank_change_13_to_16 = popularity_change_13_to_16)


I was getting the same error. You have to reverse the order of what comes before and after the = sign.

dogs<- dogs %>%
rename(avg_height_inches = avg_height,
avg_weight_lbs = avg_weight,
popularity_change_13_to_16 = rank_change_13_to_16)

WTF is this first question even asking you to do?

There’s an inconsistency between the instructions and solution code:

Q2 - Update the name of avg_height to avg_height_inches , avg_weight to avg_weight_lbs , and rank_change_13_to_16 to popularity_change_13_to_16 . Save the updated data frame to dogs .

This implies old_col is avg_height and new_col is avg_height inches.
In fact the current column name is avg_height inches, so this is incorrect.

The code for the correct answer also indicates that the old_col is avg_height_inches.
rename(avg_height_inches = avg_height,
avg_weight_lbs = avg_weight,
popularity_change_13_to_16 = rank_change_13_to_16)