data(efc)
means_by_group(efc, c12hour, e42dep)
data(iris)
means_by_group(iris, Sepal.Width, Species)
# also works for grouped data frames
if (require("dplyr")) {
efc %>%
group_by(c172code) %>%
means_by_group(c12hour, e42dep)
}
# weighting
efc$weight <- abs(rnorm(n = nrow(efc), mean = 1, sd = .5))
means_by_group(efc, c12hour, e42dep, weights = weight)
Run the code above in your browser using DataLab