psum | R Documentation |
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
.
psum(..., na.rm = FALSE)
... |
A set of vectors of the same length, a |
na.rm |
If |
Adapted from answer by Ben Bolker on StackOverflow.
A numeric vector.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.