trans: Transform Data

Description Usage Arguments Value Examples

View source: R/helper_functions.R

Description

trans transforms an object (an 'xts' for all options) by a specific formula.

Usage

1
trans(x, type = NULL, opt = NULL)

Arguments

x

'xts' object

type

type of transformation to perform.

  • log log transformation

  • l lag of time series

  • g growth rate of time series

  • gy yearly growth rate

  • d difference of time series

  • dy yearly difference

  • dv difference between x and opt

  • pdv percent diff. between x and opt

  • ldv log diff. x and opt

  • i x is indexed to opt=100

  • r transformed to Real by opt, defaults to CPI

  • s share of opt, defaults to nominal GDP

opt

additional options passed to the transformation

Value

transformed 'xts' object

Examples

1
2
3
4
5
6
7
GDP <- fred('GDP')  # Nominal GDP
rGDP <- trans('GDP', 'r', opt = fred('GDPDEF'))
GDPgap <- trans(rGDP, 'pdv', opt = fred('GDPPOT'))

Treas <- fred('GS10')         # 10 year Treasury Yield
rTreas <- trans(Treas, 'r')   # Real interest rate
trans(rTreas, 'i', '2011-01') # indexed to Jan 2011 = 100

cmann3/recon documentation built on May 13, 2019, 8:23 p.m.