rowStats | R Documentation |
Calculate some simple statistics like median, min, max or quantiles on rows in a matrix or data.frame object
rowStats(
x,
fun,
na.rm = TRUE,
q = 0.1,
weights = NULL,
run.parallel = FALSE,
keep.plan = FALSE
)
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? |
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.)
numerical vector
Simon Frey
colStats
colMin
rowMin
rowMax
colMax
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.