Learn R Programming

zoocat (version 0.2.0.1)

apply_col: Apply functions over each column

Description

Apply a function over each column of a "zoocat" object and return a data frame.

Usage

apply_col(x, ...)

# S3 method for zoocat apply_col(x, FUN, col.as = "vector", ...)

Arguments

x

A object.

...

Additional arguments to be passed to or from methods.

FUN

The function apply for each column.

col.as

If vector, each column will be treated as a vector. If zoo, each column will be treated as a zoo object.

Value

a data frame.

Examples

Run this code
# NOT RUN {
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_col(zc, FUN = mean, col.as = 'vector')
apply_col(zc, FUN = max, col.as = 'vector')

 
# }

Run the code above in your browser using DataLab