Session Ready
Exercise

Reformat variables

In the video, you saw how to use clean_names() from the janitor package to convert all variable names to snake_case. Here is how:

library(janitor)
young_bakers3 <- young_bakers3 %>% 
   clean_names()

The function clean_names() takes an argument case that can be used to convert variable names to other cases, like "upper_camel" or "all_caps".

Let's practice using the messy_ratings tibble. Remember you can use ?clean_names to see the function arguments and how to use them.

Instructions 1/3
undefined XP
  • 1

    Use glimpse() to view the variable names in messy_ratings, and load the janitor package.

    • 2

      Convert all variable names to "lower_camel" case in a new tibble called ratings; glimpse() to view again.

    • 3

      Adapt your code to convert all variable names to snake_case instead; glimpse() to view the new variable names.