Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sumKeepAttr

Sum of an Array While Keeping its Attributes


Description

This function returns the sum of an numeric array (e.g. vector or matrix) while keeping its attributes.

Usage

sumKeepAttr( x, keepNames = FALSE, na.rm = FALSE )

Arguments

x

an numeric array (e.g. vector or matrix).

keepNames

logical. Should the name(s) of the element(s) ofx be assigned to the returned sum? (only relevant if codex has only one element).

na.rm

logical. Passed to sum. Should missing values be removed?

Value

the sum (see sum).

Author(s)

Arne Henningsen

See Also

Examples

a <- 1:10
attr( a, "min" ) <- 1
attr( a, "max" ) <- 10
sum(a)
sumKeepAttr(a)

miscTools

Miscellaneous Tools and Utilities

v0.6-26
GPL (>= 2)
Authors
Arne Henningsen, Ott Toomet
Initial release
2019-12-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.