zoocat (version 0.2.0.1)

cor: Correlation computing for zoo or zoocat objects

Description

This function is based on the function stats::cor. For cor.zoo and cor.zoocat, the equality of the index of x and y will be checked (if y is not NULL). For cor.zoocat, if y has one column, the result will be binded with the cattr table and a data frame will be returned.

Usage

cor(x, y = NULL, ...)

# S3 method for zoo cor(x, y = NULL, ...)

# S3 method for zoocat cor(x, y = NULL, ...)

Arguments

x

A zoo or zoocat object.

y

NULL or a zoo or zoocat object. If NULL, x will be used.

...

Other arguments for function stats::cor.

Value

a vector, matrix or data frame.

Examples

Run this code
# NOT RUN {
x <- zoo(c(1, 3, 2, 4, 5))
y <- zoo(c(12, 30, 2, 46, 5))
cor(x, y)

x <- matrix(1 : 20, nrow = 5)
colAttr <- data.frame(month = c(2, 3, 5, 6), name = 'x')
zc <- zoocat(x, order.by = 1991 : 1995, colattr = colAttr)
y <- zoo(c(3, 5, 4, 6, 3), order.by = 1991 : 1995)
cor(zc, y, method = 'kendall')
cor(zc, method = 'kendall')


# }

Run the code above in your browser using DataCamp Workspace