apply_col: Apply functions over each column

Description Usage Arguments Value Examples

View source: R/apply_col.R

Description

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

Usage

1
2
3
4
apply_col(x, ...)

## S3 method for class '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

1
2
3
4
5
6
7
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')

 

ran-ran/zoocat documentation built on July 5, 2017, 8:41 p.m.