Skip to content

Commit

Permalink
streamline code using count instead of group_by
Browse files Browse the repository at this point in the history
  • Loading branch information
dpashouwer committed Sep 27, 2023
1 parent da31569 commit 600a146
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions vignettes/visualization-cookbook.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,7 @@ teacher_survey_he <- teacher_survey |>
teacher_survey_he_perc <- teacher_survey_he |>
drop_na("response") |>
# calculate the number of responses for each response option
group_by(question, response) |>
count(name = 'n_response') |>
ungroup() |>
count(question, response, name = 'n_response') |>
# calculate the number of responses for each question
group_by(question) |>
mutate(n_question = sum(n_response)) |>
Expand Down

0 comments on commit 600a146

Please sign in to comment.