get_switching_regime_dataframe: Extend a data frame with x(data/time), y/y2 (two numerics)...

View source: R/dataframe.R

get_switching_regime_dataframeR Documentation

Extend a data frame with x(data/time), y/y2 (two numerics) with ymin, ymx and regime

Description

The function augement a dataset with three more columns, ymin, ymax and regime, where ymin and ymax are pmin and pmax of y and y2, regime tells y>=y2 or y<=y2 happens. In addition, interpolated x observations are inserted to prevent void area in geom_ribbon usage when x is discreate

Usage

get_switching_regime_dataframe(.df, targetColumns)

Arguments

.df

a data frame to select x, y and y2 from, where x must have "POSIXct" "POSIXt" class, y and y2 are numeric

targetColumns

a named character as c("x"="x in .df", "y"="y in .df", "y2"="y2 in .df") where "zzz in .df" means column name in .df that represents zzz vector for switching regime dataset construction.

Examples

targetColumns = c("x"="year1",
  "y"="商品及服務輸出佔比", "y2"="商品及服務輸入佔比")
  get_switching_regime_dataframe(.df, targetColumns)

tpemartin/econDV2 documentation built on Aug. 6, 2023, 11:46 p.m.