View source: R/means_by_group.R
means_by_group | R Documentation |
Computes summary table of means by groups.
means_by_group(x, ...)
## S3 method for class 'numeric'
means_by_group(x, by = NULL, ci = 0.95, weights = NULL, digits = NULL, ...)
## S3 method for class 'data.frame'
means_by_group(
x,
select = NULL,
by = NULL,
ci = 0.95,
weights = NULL,
digits = NULL,
exclude = NULL,
ignore_case = FALSE,
regex = FALSE,
verbose = TRUE,
...
)
x |
A vector or a data frame. |
... |
Currently not used |
by |
If |
ci |
Level of confidence interval for mean estimates. Default is |
weights |
If |
digits |
Optional scalar, indicating the amount of digits after decimal point when rounding estimates and values. |
select |
Variables that will be included when performing the required tasks. Can be either
If |
exclude |
See |
ignore_case |
Logical, if |
regex |
Logical, if |
verbose |
Toggle warnings. |
This function is comparable to aggregate(x, by, mean)
, but provides
some further information, including summary statistics from a One-Way-ANOVA
using x
as dependent and by
as independent variable. emmeans::contrast()
is used to get p-values for each sub-group. P-values indicate whether each
group-mean is significantly different from the total mean.
A data frame with information on mean and further summary statistics for each sub-group.
data(efc)
means_by_group(efc, "c12hour", "e42dep")
data(iris)
means_by_group(iris, "Sepal.Width", "Species")
# weighting
efc$weight <- abs(rnorm(n = nrow(efc), mean = 1, sd = .5))
means_by_group(efc, "c12hour", "e42dep", weights = "weight")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.