[R] Importint stata file and using value labels

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Thu Aug 25 19:11:42 CEST 2016


You need to (re-)read the "Introduction to R" document that comes with R. R Is not Stata, and you should not expect R to look syntactically like Stata.

Note that if you, against normal R convention, wish to manipulate the integers that a factor is implemented with,  you can create such a variable using as.integer( sex ), but beware that bad data or changes made to the factor definition before your analysis step will render your assumptions about specific integer values invalid. For example the order of levels for sex might go c("M","F") or c("F","M") so 1 could mean different things based on decisions made elsewhere. 
-- 
Sent from my phone. Please excuse my brevity.

On August 25, 2016 5:09:42 AM PDT, Juan Ceccarelli Arias <jfca283 at gmail.com> wrote:
>Hi
>Im a bit lost.
>Ive imported a stata13 file. When i try to make a simple
>table(region[sex=1],type[sex=1])
>i get something as
>           type1 type2
>region1 0 0
>region2 0 0
>region3 0 0
>
>I don't know how to operate with the value labels.
>Sex is defined as 1 as "Man" and 2 as "Female".
>And region1 is 1, region2 is 2 and so on.
>So, how can i make reference to the value and not the value labels when
>i
>write down some condition or statement ?
>I know is simple, but using the help for readstata13 didn't clarify it
>to
>me.
>Thanks for your help and time.
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.



More information about the R-help mailing list