Description Usage Arguments Value Examples
Apply a function over the core data matrix of the zoocat
object,
and bind the return data with cattr
or index
.
1 2 3 4 | apply_core(x, ...)
## S3 method for class 'zoocat'
apply_core(x, FUN, bind, ...)
|
x |
the object. |
... |
other arguments for |
FUN |
the function to apply. The |
bind |
a vector of length 1 or 2 with element values to be
'cattr' or 'index' or NA to describe how to bind the return
data with |
a data frame, a "zoo
" object, or a "zoocat
" object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | x <- matrix(1 : 20, nrow = 5)
colAttr <- data.frame(month = c(2, 3, 5, 6), name = c(rep('xxx', 3), 'yyy'))
zc <- zoocat(x, order.by = 1991 : 1995, colattr = colAttr)
apply_core(zc, FUN = colMeans, bind = 'cattr')
apply_core(zc, FUN = rowMeans, bind = 'index')
apply_core(zc, FUN = function (x) {x*2}, bind = c('index', 'cattr'))
apply_core(zc, FUN = function (x) {t(x*2)}, bind = c('cattr', 'index'))
apply_core(zc, FUN = function (x) {x*2}, bind = c('index', NA))
apply_core(zc, FUN = function (x) {x[3:4, ]}, bind = c(NA, 'cattr'))
apply_core(zc, FUN = function (x)
{r <- x[3:4, ]
rownames(r) <- c('a', 'b')
return(r)},
bind = c(NA, 'cattr'))
vec <- as.vector(zc[, 1])
apply_core(zc, FUN = function (x) {cor(x, vec)}, bind = 'cattr')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.