Skip to content

Instantly share code, notes, and snippets.

@dwillis
Last active September 27, 2021 18:38
Show Gist options
  • Save dwillis/8c3b668c16bd5ee201cb278e273b8af4 to your computer and use it in GitHub Desktop.
Save dwillis/8c3b668c16bd5ee201cb278e273b8af4 to your computer and use it in GitHub Desktop.
my_data %>%
mutate(
category = case_when(
amount < 10000 ~ 'under_10k',
amount < 50000 ~ '10k_50k',
amount < 100000 ~ '50k_100k',
amount < 500000 ~ '100k_500k',
amount < 1000000 ~ '500k_1m',
amount > 1000000 ~ '1m_plus'
)
) %>%
group_by(category) %>%
summarise(count = n())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment