apply,dual-method | R Documentation |
This method generalizes 'base::apply' to dual objects.
## S4 method for signature 'dual'
apply(X, MARGIN, FUN, ..., simplify = TRUE)
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 |
The returned value depends on the values returned by 'FUN', similarly to 'base::apply'
apply
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.