varToFactor function

Change the a keyVariable of an object of class sdcMicroObj-class from Numeric to Factor or from Factor to Numeric

Change the a keyVariable of an object of class sdcMicroObj-class from Numeric to Factor or from Factor to Numeric

Change the scale of a variable methods

varToFactor(obj, var) varToNumeric(obj, var)

Arguments

  • obj: object of class sdcMicroObj-class
  • var: name of the keyVariable to change

Returns

the modified sdcMicroObj-class

Examples

## for objects of class sdcMicro: data(testdata2) sdc <- createSdcObj(testdata2, keyVars=c('urbrur','roof','walls','water','electcon','relat','sex'), numVars=c('expend','income','savings'), w='sampling_weight') sdc <- varToFactor(sdc, var="urbrur")