apply_col: Apply functions over each column

Description Usage Arguments Value Examples

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')

 

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: reshape2

Attaching package: 'zoocat'

The following object is masked from 'package:stats':

    cor

  month name output
1     2  xxx      3
2     3  xxx      8
3     5  xxx     13
4     6  yyy     18
  month name output
1     2  xxx      5
2     3  xxx     10
3     5  xxx     15
4     6  yyy     20

zoocat documentation built on May 2, 2019, 10:22 a.m.