Skip to content

Instantly share code, notes, and snippets.

@dwillis
Created February 15, 2022 19:23
Show Gist options
  • Save dwillis/52bfadf9ca8f8a685f2a8cca2ec7beeb to your computer and use it in GitHub Desktop.
Save dwillis/52bfadf9ca8f8a685f2a8cca2ec7beeb to your computer and use it in GitHub Desktop.
Sample template for basic filtering, mutate and group_by with count
```{r}
my_result <- original_data %>%
filter(some_column == "some value") %>%
mutate(some_column=str_to_title(some_column)) %>%
group_by(some_column) %>%
summarise(new_aggregate = n()) %>%
arrange(desc(new_aggregate))
```
```{r}
my_result <- original_data %>%
filter(some_column == "some value") %>%
mutate(some_column=str_to_title(some_column)) %>%
group_by(some_column) %>%
summarise(new_aggregate = sum(some_number_column)) %>%
arrange(desc(new_aggregate))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment