Learn R Programming

dse (version 2006.10-1)

ytoypc: Convert to year to year percent change

Description

Convert level data to year over year percent change.

Usage

ytoypc(obj, names = paste("y to y %ch", seriesNames(obj)))
    ## S3 method for class 'default':
ytoypc(obj, names = paste("y to y \%ch", seriesNames(obj)))

Arguments

obj
A time series object.
names
names for the new series (but is details).

Value

  • A time series vector or matrix.

Details

The result is a time series of the year over year percent change. This uses percentChange with lag=frequency(obj).

The names are not applied to the new series if the global option ModSeriesNames is FALSE. This can be set with options(ModSeriesNames=FALSE). This provides a convenient mechanism to prevent changing series labels on plot axis, when the title may indicate that data is in year-to-year percent change so the axis label does not need this.

See Also

percentChange

Examples

Run this code
z <- matrix(100 + rnorm(200),100,2)
z[z == 0] <- 1 # not to likely, but it can happen
z <- ytoypc(z)

Run the code above in your browser using DataLab