Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assuming the group means are stored in a tibble called group_means, you can use the summarize function to calculate the median without the need to rejoin a temporary tibble. Here's an example:

library(dplyr)

group_means <- iris %>% 
  group_by(Species) %>% 
  summarize(mean = mean(Sepal.Length))

median_of_means <- group_means %>% 
  summarize(median = median(mean))

median_of_means

This code calculates the mean of Sepal.Length for each Species group in the iris dataset and stores the results in group_means. It then uses summarize again to calculate the median of the mean column in group_means and stores the result in median_of_means.