| interact_them {Colossus} | R Documentation |
Defines Interactions
Description
interact_them uses user provided interactions define interaction terms and update the data.table. assumes interaction is "+" or "*" and applies basic anti-aliasing to avoid duplicates
Usage
interact_them(df, interactions, new_names, verbose = FALSE)
Arguments
df |
a data.table containing the columns of interest |
interactions |
array of strings, each one is of form term1?*?term2" for term1 interaction of type * or + with term2, "?" dlimits |
new_names |
list of new names to use instead of default, default used if entry is ” |
verbose |
boolean to control if additional information is printed to the console, also accepts 0/1 integer |
Value
returns a list with two named fields. df for the updated dataframe, and cols for the new column names
See Also
Other Data Cleaning Functions:
Check_Dupe_Columns(),
Check_Trunc(),
Correct_Formula_Order(),
Date_Shift(),
Def_Control(),
Def_Control_Guess(),
Def_model_control(),
Def_modelform_fix(),
Joint_Multiple_Events(),
Replace_Missing(),
Time_Since(),
factorize(),
factorize_par(),
gen_time_dep()
Examples
library(data.table)
a <- c(0,1,2,3,4,5,6)
b <- c(1,2,3,4,5,6,7)
c <- c(0,1,2,1,0,1,0)
df <- data.table::data.table("a"=a,"b"=b,"c"=c)
interactions <- c("a?+?b","a?*?c")
new_names <- c("ab","ac")
vals <- interact_them(df, interactions, new_names)
df <- vals$df
new_col <- vals$cols