Use the userObjects argument along with the transforms argument to create new variables from objects in your global environment (or other environments in your current search path).
For example, suppose you would like to estimate a linear model using wage income as the dependent variable, and want to include state-level of per capita expenditure on education as one of the independent variables. We can define a named vector to contain this state-level data as follows:
educExp <- c(Connecticut=1795.57, Washington=1170.46, Indiana = 1289.66)
We can then use rxDataStepXdf to add the per capita education expenditure as a new variable using the transforms argument, passing educExp to the userObjects argument as a named list:
censusWorkers <- file.path(rxGetOption("sampleDataDir"), "censusWorkers.xdf") rxDataStepXdf(inFile = censusWorkers, outFile = "censusWorkersWithEduc", transforms=list(stateEducExpPC=educExp[match(state, names(educExp))]), transformVars="state", userObjects=list(educExp=educExp))
The rxGetInfoXdf function reveals the added variable:
rxGetInfo("censusWorkersWithEduc.xdf",getVarInfo=TRUE)
This example and other are included in the RevoScaleR User's Guide, accessed by selecting Help - R Manuals (PDF) from the Revolution R Enterprise menu.
For example, suppose you would like to estimate a linear model using wage income as the dependent variable, and want to include state-level of per capita expenditure on education as one of the independent variables. We can define a named vector to contain this state-level data as follows:
educExp <- c(Connecticut=1795.57, Washington=1170.46, Indiana = 1289.66)
We can then use rxDataStepXdf to add the per capita education expenditure as a new variable using the transforms argument, passing educExp to the userObjects argument as a named list:
censusWorkers <- file.path(rxGetOption("sampleDataDir"), "censusWorkers.xdf") rxDataStepXdf(inFile = censusWorkers, outFile = "censusWorkersWithEduc", transforms=list(stateEducExpPC=educExp[match(state, names(educExp))]), transformVars="state", userObjects=list(educExp=educExp))
The rxGetInfoXdf function reveals the added variable:
rxGetInfo("censusWorkersWithEduc.xdf",getVarInfo=TRUE)
This example and other are included in the RevoScaleR User's Guide, accessed by selecting Help - R Manuals (PDF) from the Revolution R Enterprise menu.