You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reduce length of individual commands to allow for easier typing and streamline to allow sufficient time for later material, specifically cleaning 'messy' data.
The text was updated successfully, but these errors were encountered:
mutate(series = recode(series, "Emissions (thousand metric tons of carbon dioxide)" = "total",
"Emissions per capita (metric tons of carbon dioxide)" = "per_capita")) %>%
For (1) I propose that we skip the col_names argument and use the rename verbs. I think this is a bit better because it can be easy to mix up column names and not realize it especially if data formats change over time. At least with explicit renames it's more clear what the intention is. WIth the latest version of dplyr/readr I think it makes sense to instead use
For (2), the concern was that you just have to type really long names exactly for the recode to work and the IDE can't provide autocomplete in that case. An alternative to consider would be case_when. For example
Unfortunately case_when isn't the most straightforward function to use but it can help out with a lot of data manipulation tasks. But it's kind of annoying to have to explain the ~ syntax. So an alternative would just be if_else
mutate(series = if_else(str_starts(series, "Emissions per capita"), "per_capita", "total"))
which works find when there are just two categories.
If anyone has other suggestions, let me know. Otherwise if these look good, I can create a pull request for the changes.
Reduce length of individual commands to allow for easier typing and streamline to allow sufficient time for later material, specifically cleaning 'messy' data.
The text was updated successfully, but these errors were encountered: