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

2007-07-30 Thread Ben Saylor
Thanks for the clarification.  I found the labels  values in

attributes(dataframe)$label.table$varname

which looks the same whether convert.factors is TRUE or FALSE.

Ben

Thomas Lumley wrote:
 On Thu, 26 Jul 2007, Ben Saylor wrote:
 
 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.
 
 Yes. The R factor type should not be used if you want the original 
 levels. It is not a 'labelled numeric' type and the numbers are an 
 implementation detail.
 
  Using convert.factors=FALSE
 preserves the values, but seems to discard the labels.
 
 It doesn't discard the labels. They are kept in the attributes of the 
 data frame.
 
 -thomas

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2007-07-26 Thread Ben Saylor
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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.