Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Create new variables
4. Create a new column
Grouping and statistical functions
Joining datasets
Summary

Instruction

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",
  TRUE, FALSE))

Exercise

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

Stuck? Here's a hint!

Type:

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