mean_: mean_

Description Usage Arguments Details Examples

View source: R/mean_.R

Description

Generic function for the arithmetic mean of a list or vector.

Usage

1
mean_(x, group = NULL, sd = NULL, ...)

Arguments

x

A vector or list with values. For more details see mean.

group

A vector or list with values giving groups for which a mean shall be calculated. Default is NULL. Will arrange the groups in an increasing order.

sd

A numeric value. If not NULL (the default) se() will be used and the result will be multiplied with the given value. This way, 1 means the standard deviation while it can also be used to calculate the confidence intervals (1.96).

...

further arguments possible for mean() or sd().

Details

Calculates the mean for a vector (just like mean()) or list (adding unlist() before calculating the mean). Can also create a mean for different groups with 'group' and will apply unlist() and unique() to 'group' beforehand so 'group' as well can be a list. If 'se' is not NULL (the default) the standard deviation is calculated and multiplied with the value given in 'se' (1 = sd; 1.96 = CI). The output will be a tibble with one, two or three columns depending on which parameters are given initially. If 'group' is given, there will be rows equaling the number of unique values in 'group' instead of 1.

Examples

1
2
3
4
5
#rm(list = ls())
group <- c(2, 2, 2, 1, 1, 1, 1)
x <- c(1, 2, 3, 4, 5, 6, NA)
sd <- 1
test <- mean_(x, group, sd, na.rm = TRUE)

reneplonus/ototools documentation built on May 3, 2019, 4:05 p.m.