asum | R Documentation |
Sum over specified dimension margins.
## S3 method for class 'spray'
asum(S, dims, drop=TRUE, ...)
asum_inverted(S, dims)
process_dimensions(S,dims)
S |
spray object |
dims |
Vector of strictly positive integers corresponding to dimensions to be summed over |
drop |
Boolean, with default |
... |
Further arguments, currently ignored |
Function asum.spray()
is the method for asum()
. This
takes a spray, and a vector of integers corresponding to dimensions to
be summed over.
Function asum_inverted()
is the same, but takes a vector of
integers corresponding to dimensions not to sum over. This function is
here because there is nice C++
idiom for it.
Function process_dimensions()
ensures that the dims
argument is consistent with the spray S
and returns a cleaned
version thereof.
Returns a spray object.
Robin K. S. Hankin
S <- spray(matrix(sample(0:2,60,replace=TRUE),ncol=3),addrepeats=TRUE)
S
asum(S,1)
asum(S,1:2)
asum(S,1:2,drop=FALSE)
asum(S,c(1,3)) == asum_inverted(S,2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.