Yearly aggregation function

Description

This function allows for the aggregation of non-continuos time series data into years. It allows for the multiple years to be specified. The aggregation method is also allowed to be set by the user. It also allows for the aggregation block to start at first observation or from the start of the year.

Usage

1
yearsAgg(data, process, multiple = NULL, na.rm = FALSE,from.first.obs = TRUE)

Arguments

data

A timeSeries formatted dataset.

process

An aggregation method. See aggregate.

multiple

An integer specifying the aggregation block. Default

na.rm

Default is na.rm=FALSE.

from.first.obs

Wether the years start from the first observation or from the beginning of the year. Default is from.first.obs=TRUE.

Details

This function is based on the aggregate method. It is designed to simplify the process of aggregating non-continuos data.

Value

Returns a data.frame with dates formatted as as.Date and aggregated data.

Author(s)

Jason Lessels <jason.lessels@sydney.edu.au>

See Also

aggregate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
##Load the foo data
data(foo)
##Format the data using the timeSeries function. 
foo.ts<-timeSeries(foo[,1],  "%d/%m/%Y   %H:%M",foo[,3])
##Aggregate the data into years from first observation
year.mean <-yearsAgg(foo.ts,mean)
plot(year.mean)
##Now plot the min mean and max on one plot.
year.min <-yearsAgg(foo.ts,min)
year.max <-yearsAgg(foo.ts,max)
ymin=min(year.min$data);ymax=max(year.max$data)
plot(year.mean,ylim=c(ymin,ymax))
lines(year.min,type="l",lty=3,col="red")
lines(year.max,type="l",lty=3,col="blue")