apply,dual-method {salad} | R Documentation |
Apply functions over array margins of dual objects
Description
This method generalizes 'base::apply' to dual objects.
Usage
## S4 method for signature 'dual'
apply(X, MARGIN, FUN, ..., simplify = TRUE)
Arguments
X |
a dual object (with array or matrix shape) |
MARGIN |
a vector giving the subscript which the function will be applied over |
FUN |
the function to be applied |
... |
extra arguments for 'FUN' |
simplify |
a logical indicating whether the results should be simplified |
Value
The returned value depends on the values returned by 'FUN', similarly to 'base::apply'
See Also
Examples
A <- matrix( c(1,2,3,4), 2, 2)
x <- dual(A)
cs <- apply(x, 2, sum)
cs
d(cs)
# prefered method for summing over the columns
colSums(x)
[Package salad version 1.0 Index]