[R] reading stata files: preserving values of variables converted to factors

Ben Saylor bensaylor at fastmail.fm
Fri Jul 27 02:38:34 CEST 2007


Hi,

I am a Stata user new to R.  I am using read.dta to read a Stata file 
that has variables with value labels.  read.dta converts them to 
factors, but seems to recode them with values from 1 to <number of 
factor levels> (looking at the output of unclass(<varname>)), so the 
original numerical values are lost.  Using convert.factors=FALSE 
preserves the values, but seems to discard the labels.  Is it possible 
to get these variables into R while preserving both the values and the 
labels?

Thanks,
Ben



More information about the R-help mailing list