R/sumKeepAttr.R

Defines functions sumKeepAttr

Documented in sumKeepAttr

## return the sum of an array while keeping its attributes
sumKeepAttr <- function( x, keepNames = FALSE, na.rm = FALSE ) {
   xAttr <- attributes( x )
   if( !keepNames ) {
      xAttr$names <- NULL
   }
   x <- sum( x, na.rm = na.rm )
   mostattributes( x ) <- xAttr
   return( x )
}

Try the miscTools package in your browser

Any scripts or data that you put into this service are public.

miscTools documentation built on Dec. 9, 2019, 3 a.m.