Choosing among the four verbs
In this chapter you've learned about the four verbs: select(), mutate(), relocate(), and rename(). Here, you'll choose the appropriate verb for each situation. You won't need to change anything inside the parentheses.
Deze oefening maakt deel uit van de cursus
Data Manipulation with dplyr
Oefeninstructies
- Choose the right verb for changing the name of the
unemploymentcolumn tounemployment_rate - Choose the right verb for keeping only the columns
state,county, and the ones containingpoverty. - Calculate a new column called
fraction_womenwith the fraction of the population made up of women, without dropping any columns. - Keep only three columns: the
state,county, andemployed / population, which you'll callemployment_rate.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Change the name of the unemployment column
counties %>%
___(unemployment_rate = unemployment)
# Keep the state and county columns, and the columns containing poverty
counties %>%
___(state, county, contains("poverty"))
# Calculate the fraction_women column without dropping the other columns
counties %>%
___(fraction_women = women / population)
# Move the region column to before state
counties %>%
___(region, .before = state)