Transform: Transformation of zoo object

Description Usage Arguments Value Examples

View source: R/Transform.r

Description

Adds new columns to zoo object with transformed data; applies for all columns in 'data'

Usage

1
2
3
Transform(data, start = "01/01/1666", end = "01/01/1666",
  chg = "none", chg_type = "perc", pma = "none", pms = "none",
  lag = "none", rebase = "FALSE", Z = "none")

Arguments

data

specification of zoo object

start

optional start date to trim 'data'; format is 'dd/mm/yyyy'

end

optional end date to trim 'data'; format is 'dd/mm/yyyy'

chg

optional string to calculate periodical changes; options are 'YoY' (Year-on-Year), 'QoQ' (Quarter-on-Quarter), 'MoM' (Month-on-Month), 'WoW' (Week-on-Week), 'DoD' (Day-on-Day)

chg_type

optional string to specify calculation of changes; options are 'perc' (percentage change) or 'delta' (difference)

pma

optional integer to specify number of data points for calculation of period-moving-averages

pms

optional integer to specify number of data points for calculation of period-moving-sums

lag

optional integer to lag the data by a number of periods; use negative integer for lead

rebase

optional boolean to rebase the data to 100 at first observation

Z

optional integer (or character) to specify the rolling number of periods over which the data is normalized; use 'all' to compute z-scores over all available periods

Value

returns a zoo object with original and transformed data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Note that these examples require corresponding zoo objects to work properly

zoo <- Transform(data = zoo, chg = "YoY", chg_type = 'perc')
zoo <- Transform(data = zoo, chg = "MoM", chg_type = "delta")
zoo <- Transform(data = zoo, start = "01/01/2010", pma = 12)
zoo <- Transform(data = zoo, pma = 3)
zoo <- Transform(data = zoo, pms = 6)
zoo <- Transform(data = zoo, lag = 3)
zoo <- Transform(data = zoo, lag = -3)
zoo <- Transform(data = zoo, rebase = TRUE)
zoo <- Transform(data = zoo, Z = 12)
zoo <- Transform(data = zoo, Z = all)

kilianreber/chartbookR documentation built on July 19, 2019, 9:48 a.m.