colStats: Calculate some simple statistic estimators on cols in a...

View source: R/rowcolstats.r

colStatsR Documentation

Calculate some simple statistic estimators on cols in a matrix or data.frame

Description

Calculate some simple statistics like median, min, max or quantiles on columns in a matrix or data.frame object

Usage

colStats(x, fun, na.rm = TRUE, q = 0.1, weights = NULL, run.parallel = FALSE)

Arguments

x

numerical matrix or data.frame.

fun

statistical function that will be calculated. See details.

na.rm

logical. Should NA values be removed?

q

numerical. Quantile that will be estimated. Used only if fun == quantile.

weights

numerical vector. Used if fun == weighted.quantile only. See details.

run.parallel

logical. Should the operation be run in parallel? If TRUE, future_apply with the plan "multisession" is used.

Details

This function uses predefined statistical function that can be used:

  • min (determine the minimum value)

  • max (determine the maximum value)

  • mean (estimate the mean value)

  • median (estimate the median value)

  • quantile (estimate a certain quantile value. Note that values between 0 and 1 are accepted)

  • weighted.quantile (calculation of quantiles using individual weights. Quantile from DescTools is used.)

Value

numerical vector

Author(s)

Simon Frey

See Also

rowStats

colMin

rowMin

rowMax

colMax

Examples

    # load runoff data
    data(runoff)
    
    colStats(runoff, fun = "mean")
    colStats(runoff, fun = "max")
    colStats(runoff, fun = "quantile", q = 0.33)

freysimon/TigR documentation built on April 20, 2024, 9:28 p.m.