Last data update: 2014.03.03

R: Adds actual numeric regressors for factor to dataframe as new...
varRegressorsR Documentation

Adds actual numeric regressors for factor to dataframe as new variables

Description

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

Usage

varRegressors(Data, VarName, RegressorNames = NULL)

Arguments

Data

The dataframe to add regressors

VarName

Character string name of variable to code regressor for

RegressorNames

Optional variable names for regressors.

Value

Returns original data frame (Data) with addition of new regressors.

Author(s)

John J. Curtin jjcurtin@wisc.edu

Examples

d = Ornstein
contrasts(d$nation) = varContrasts(d$nation, Type='POC', 
   POCList = list(c(3,-1,-1, -1),c(0,2,-1, -1), c(0,0,1,-1)))
d = varRegressors(d,'nation')

Results