monthly {Animal}R Documentation

Calculate monthly values from time series

Description

Calculate monthly values (e.g mean or sum) from time series data. Allows to specify a subject to calculate monthly values for several subjects.

Usage

monthly(data, time, fun = sum, subject = NULL)

Arguments

data A data vector that you want to calculate the monthly values for
time Time stamps for data in POSIXct format
fun The function to apply, defaults to sum
subject You can optionally specify to a subject. e.g. to get monthly values for each cow in a herd.

Value

A data.frame with following elements

Day Date
Subject Appears only if you have specified a subject
Result The result of the function

Author(s)

Matti Pastell <matti.pastell@helsinki.fi>

See Also

monthly, hourly, weekly

Examples

data(RIC)
RIC2 <- clean.RIC(RIC)
#Monthly feed intake of a whole from data set RIC
herd <- monthly(RIC2$intake,time=RIC2$begin,fun=sum)
#Monthly feed intake of individual cows from data set RIC
herd <- monthly(RIC2$intake,time=RIC2$begin,fun=sum,subject=RIC2$cowID)

[Package Animal version 1.01 Index]