psum {statisfactory} | R Documentation |
Element-by-element sum
Description
This function is similar to pmax
or pmin
, except that it returns the element-wise sum of values. If the input is a matrix
or data.frame
, the output is the same as colSums
.
Usage
psum(..., na.rm = FALSE)
Arguments
... |
A set of vectors of the same length, a |
na.rm |
If |
Details
Adapted from answer by Ben Bolker on StackOverflow.
Value
A numeric vector.
Examples
x1 <- 1:10
x2 <- runif(10)
psum(x1, x2)
x <- cbind(x1, x2)
psum(x)
x2[3] <- NA
psum(x1, x2)
psum(x1, x2, na.rm=TRUE)
[Package statisfactory version 1.0.4 Index]