weekly {Animal} | R Documentation |
Calculate weekly values (e.g mean or sum) from time series data. Allows to specify a subject to calculate weekly values for several subjects.
weekly(data, time, fun = sum, subject = NULL)
data |
A data vector that you want to calculate the weekly 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 weekly values for each cow in a herd. |
A data.frame with following elements
Week |
Week number |
Subject |
Appears only if you have specified a subject |
Result |
The result of the function |
Matti Pastell <matti.pastell@helsinki.fi>
data(RIC) RIC2 <- clean.RIC(RIC) #Weekly feed intake of a whole from data set RIC herd <- weekly(RIC2$intake,time=RIC2$begin,fun=sum) #Weekly feed intake of individual cows from data set RIC herd <- weekly(RIC2$intake,time=RIC2$begin,fun=sum,subject=RIC2$cowID)