I would like to output the summary statistics (average, maximum, minimum, etc.) for group1 and group2 for the following data frames:I would appreciate it if you could let me know.
Example)
Average value of Group A for Men =
Average value of Men in Group B =
Average value of Group A for Women =
Average value of Group B for Women =
df<-data.frame(age=1:100, group1=c(rep("Men", 50), rep("Women", 50), group2=c(rep("A", 25), rep("B", 25), rep("C", 25), rep("D", 25)))
suppressMessages (library(tidyverse))
df%>%split(list(.$group1,.$group2))%>%Filter(function(x)nrow(x)>0,.)%>%map(~summary(.$age))
© 2024 OneMinuteCode. All rights reserved.