Learn R Programming

pastecs (version 1.0-2)

buysbal: Buys-Ballot table

Description

Calculate a Buys-Ballot table from a time-series

Usage

buysbal(x, y=NULL, frequency=12, units="years", datemin=NULL,
        dateformat="m/d/Y", count=FALSE)

Arguments

x
Either a vector with time values (in this case, y must be defined), or a regular time-series
y
If x is a vector with time values, y must contain corresponding observations
frequency
The frequency of observations per year to use in the Buys-Ballot table. By default frequency=12 which corresponds to monthly samples, and the resulting table has 12 column, one per month
units
either "years" (by default), and time is not rescaled, or "days", and the time is rescaled to "years" with the function daystoyears()
datemin
A character string representing the first date, using a format corresponding to dateformat. For instance, with datemin="04/23/1998" and dateformat="m/d/Y", the first observation is assumed to be made the 23th April 1
dateformat
The format used for the date in datemin. For instance, "d/m/Y" or "m/d/Y" (by default). The distinction between "Y" and "y" is not important in Splus, but it is vital in Rto use "y" for two-digit years (ex: 89) and "
count
If FALSE (by default), the Buys-Ballot table is calculated. If TRUE, the function returns only the number of observations that are used in each cell of the Buys-Ballot table

Value

  • A matrix containing either the Buys-Ballot table (count=FALSE), or the number of observations used to build the table (count=TRUE)

Details

A Buys-Ballot table summarizes data to highlight seasonal variations. Each line is one year and each column is a period of the year (12 months, 4 quarters, 52 weeks,...). A cell ij of this table contain the mean value for all observations made during the year i at the period j.

See Also

daystoyears, tsd

Examples

Run this code
data(releve)
buysbal(releve$Day, releve$Melosul, frequency=4, units="days",
        datemin="21/03/1989", dateformat="d/m/Y")
buysbal(releve$Day, releve$Melosul, frequency=4, units="days",
        datemin="21/03/1989", dateformat="d/m/Y", count=TRUE)

Run the code above in your browser using DataLab