Adds new variables/columns in dataframe to represent numeric regressors for a factor. Factors are coded using their currently defined contrast codes. This function is useful for control of a factor covariate when graphing and ignoring this factor and/or other lower-level control variables. For this purpose, POC coding will typically be set for factor prior to using lm.codeRegressor
varRegressors(Data, VarName, RegressorNames = NULL)
The dataframe to add regressors
Character string name of variable to code regressor for
Optional variable names for regressors.
Returns original data frame (Data) with addition of new regressors.
# NOT RUN {
##NOT RUN
##data(BAC)
##BAC$Sex = factor(BAC$Sex)
##BAC = varRegressors(BAC,'Sex')
# }
Run the code above in your browser using DataLab