Ask Your Question
0

How can the median of group means be obtained within the existing piped workflow without the need to rejoin a temporary tibble?

asked 2021-07-03 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-04-13 12:00:00 +0000

lakamha gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-07-03 11:00:00 +0000

Seen: 12 times

Last updated: Apr 13 '21