-1

The pipeline

warpbreaks %>%
group_by(wool, tension) %>%
summarise_at(vars(breaks), list(~mean(.), ~median(.), ~sd(.)))

Could someone interpret the summarise_at() part of the code for me?

Sadra Saderi
  • 52
  • 1
  • 8
LennyB51
  • 21
  • 3
  • It summarizes the data *at* the variable (column) named `breaks`, and runs three functions on that data. Now that you know that, it's time to highlight that `summarise_at` has been [superseded](https://dplyr.tidyverse.org/reference/summarise_all.html) by `across`, where the call would be `summarise(across(breaks, list(~mean(.), ~median(.), ~sd(.))))` (though the naming is slightly different). – r2evans Feb 09 '21 at 14:22
  • I don't think that StackOverflow is meant to be a place to ask questions like this, perhaps that's why you received a downvote. Please do some research before asking questions, where for tidyverse packages I'd start with the canonical (and well-documented with complete examples) https://dplyr.tidyverse.org/. Please continue asking questions, but please do some research before asking a new question here. Thank you. – r2evans Feb 09 '21 at 14:26

1 Answers1

0
summarize_at(vars, function)

The first argument vars() to summarize_at lets you select the specific set of variables that you would like to perform the function on.

In your case, your code will get the mean, median, and standard deviation for the breaks variable in a list form.

shinyy
  • 9
  • 4