| grpmean {sjstats} | R Documentation |
Computes mean, sd and se for each sub-group (indicated by grp)
of dv.
grpmean(x, dv, grp, weight.by = NULL, digits = 2, out = c("txt", "viewer",
"browser"))
x |
A (grouped) data frame. |
dv |
Name of the dependent variable, for which the mean value, grouped
by |
grp |
Factor with the cross-classifying variable, where |
weight.by |
Vector of weights that will be applied to weight all cases.
Must be a vector of same length as the input vector. Default is
|
digits |
Numeric, amount of digits after decimal point when rounding estimates and values. |
out |
Character vector, indicating whether the results should be printed
to console ( |
This function performs a One-Way-Anova with dv as dependent
and grp as independent variable, by calling
lm(count ~ as.factor(grp)). Then contrast
is called to get p-values for each sub-group. P-values indicate whether
each group-mean is significantly different from the total mean.
For non-grouped data frames, grpmean() returns a data frame with
following columns: term, mean, N, std.dev,
std.error and p.value. For grouped data frames, returns
a list of such data frames.
data(efc) grpmean(efc, c12hour, e42dep) data(iris) grpmean(iris, Sepal.Width, Species) # also works for grouped data frames library(dplyr) efc %>% group_by(c172code) %>% grpmean(c12hour, e42dep)