rowStats: Calculate some simple statistic estimators on rows in a...

View source: R/rowcolstats.r

rowStatsR Documentation

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

Description

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

Usage

rowStats(
  x,
  fun,
  na.rm = TRUE,
  q = 0.1,
  weights = NULL,
  run.parallel = FALSE,
  keep.plan = 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.

keep.plan

logical. Should the plan "multisession" be kept or changed back to "sequential" by quitting the function?

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. \link{Quantile} from \code{DescTools} is used.)

Value

numerical vector

Author(s)

Simon Frey

See Also

colStats

colMin

rowMin

rowMax

colMax

Examples

    # load runoff data
    data(runoff)
    
    rowStats(runoff, fun = "mean")
    rowStats(runoff, fun = "max")
    rowStats(runoff, fun = "quantile", q = 0.33)
    rowStats(runoff, fun = "weighted.quantiles", q = 0.33, weights = c(1,1,1,4,1,1))

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