Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
Create new variables
4. Create a new column
Grouping and statistical functions
Joining datasets


Good job! But one more thing – we need to assign this result to a new variable!

To assign data to a variable calculated by %>%, we start with the new variable name. Next, we list the dataset and write the operation(s) that will generate the data.

In our earlier example, this would be:

countries2 <-
  countries %>%
  mutate(america = if_else(continent == "North America" | continent == "South America",


Assign the result of the query from the previous exercise to the countries_urban variable.

Stuck? Here's a hint!


countries_urban <- countries %>%
  mutate(urban_country = if_else(urban_pop_pc >= 65, TRUE, FALSE))