add_var_cols: Add Variance Columns for 3612 Reports

Description Usage Arguments Note

View source: R/add_var_cols.R

Description

These function adds variance and percent variance columns to a data.table for each of the vars specified. add_var_cols2() performs the same operations as add_var_cols2() but it also rehsapes the data.table using data.table's dcast() based on the variable names provided in row_vars.

Usage

1
2
3
4
5
6
add_var_cols(D, vars = c("cost_pmpm", "claims_per_1000",
  "cost_per_claim"), reorder = T, format.pct = T)

add_var_cols2(D, vars = c("cost_pmpm", "claims_per_1000",
  "cost_per_claim"), reorder = T, format.pct = T,
  row_vars = c("product", "region", "mmcor_desc"))

Arguments

D

A data.table

vars

A character vector of column names to use to calculate new variance columns

reorder

Logical, if TRUE (default) then reorders the columns in the order the vars are specified - order goes as follows: prior, current, var, var_pct

format.pct

Logical, if TRUE (default) then pct_change() will format the percentage variable

row_vars

A character vector of column names that will serve as the unique rows of the final data.table - usually product, region, and mmcor_desc

Note

add_var_cols() does not need to be reassigned to an R object, however add_var_cols2() does need to be reassigned. Variables cannot be included in both var and row_vars and variables appearing in neither are automatically dropped. If using add_var_cols2() a column col must exist containing two values 'prior' and 'current'.


joshua-ruf/fidelis documentation built on July 20, 2019, 1:56 a.m.