summary_mean: Mean function

Description Usage Arguments Value Author(s) Examples

View source: R/summary_functions.R

Description

Function that returns the arithmetic mean an R object. Allows trimming of values and flexible definition of missing values.

Usage

1
summary_mean(x, na.rm = FALSE, trim = 0, na_type = "", ...)

Arguments

x

An R object.

na.rm

A logical value indicating whether missing values should be stripped before the computation proceeds.

trim

A fraction between 0 and 0.5 of observations to be trimmed from each end of x before mean is computed.

na_type

A vector of strings that defines the type of missing value criteria e.g "n", "con", "prop", "FUN".

...

Additional parameters that could be passed internally. for example "na_consecutive_n = 3" to define the maximum allowed number of consecutive missing values. Other parameters include "na_max_n", "na_min_n", "n_non_miss", "na_max_prop" for maximum, minimum and proportion of missing values

Value

Returns the average value.

Author(s)

Shadrack Kibet

Examples

1
2
3
4
x <- c(1:10, NA, NA, NA, 2, 5, 6, 7)
summary_mean(x, na.rm = TRUE, na_type = "n", na_max_n = 2)
summary_mean(x, na.rm = TRUE, na_type = "n_non_miss", na_min_n = 2)
summary_mean(x, na.rm = TRUE, na_type = "con", na_consecutive_n = 2)

shadrackkibet/summaryR documentation built on Jan. 2, 2020, 12:54 a.m.