Answer by user10917479 for Tidy way to get `summary` output per group?
Here is a concise tidyverse way.library(dplyr)library(purrr)library(tidyr)data %>% nest_by(year) %>% mutate(data = map(data, summary)) %>% unnest_wider(data)# # A tibble: 4 x 7# year Min. `1st...
View ArticleAnswer by jdobres for Tidy way to get `summary` output per group?
Another possible tidyverse solution. Same basic idea as Rui's solution above, but a little more verbose since it uses nest() and unnest() before pivoting back to wide data.library(tidyverse)data <-...
View ArticleAnswer by Rui Barradas for Tidy way to get `summary` output per group?
Base R solutionTry with by followed by do.call/rbind.do.call(rbind, by(data$x, data$year, summary))# Min. 1st Qu. Median Mean 3rd Qu. Max.#2018 0.45126737 0.5437956 0.6363238 0.6343376 0.7258727...
View ArticleTidy way to get `summary` output per group?
My code frequently uses tapply and summary as shown below:data <- tibble( year = rep(2018:2021, 3), x = runif(length(year)))tapply(data$x, data$year, summary)The output looks like:$`2018` Min. 1st...
View Article