Juan Ceccarelli Arias
2016-Aug-25 16:49 UTC
[R] Importint stata file and using value labels
> str(sex)Factor w/ 2 levels "Hombre","Mujer": 1 2 2 1 2 2 1 1 1 1 ... On Thu, Aug 25, 2016 at 1:42 PM, <ruipbarradas at sapo.pt> wrote:> Maybe sex is a factor and Man its label. Factors are coded internally as > integers, to see it use > > str(sex) > > Rui Barradas > > > Citando Juan Ceccarelli Arias <jfca283 at gmail.com>: > > Nop. I didn't work. But using the following it does work. > table(region[sex=="Men"],type[sex=="Men"]) > When i use the dta file with stata i declare the condition with sex==1 and > not sex=="Man". > > On Thu, Aug 25, 2016 at 12:39 PM, <ruipbarradas at sapo.pt> wrote: >> >> >> >> >> >> *Hello, Try instead table(region[sex==1],type[sex=*=1]) >> >> To test for equality use == not =. >> >> Hope this helps, >> >> Rui Barradas >> >> >> *Citando Juan Ceccarelli Arias <jfca283 at gmail.com <jfca283 at gmail.com>>:* >> >> >> >> >> >> *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/posti >> ng-guide.htmland provide commented, minimal, self-contained, >> reproducible code. >> >> >> >> >> >> > > >[[alternative HTML version deleted]]
ruipbarradas at sapo.pt
2016-Aug-25 19:11 UTC
[R] Importint stata file and using value labels
So you should do table(region[sex=="Hombre"],type[sex=="Hombre"] Rui Barradas ? Citando Juan Ceccarelli Arias <jfca283 at gmail.com>:>> str(sex) > ?Factor w/ 2 levels "Hombre","Mujer": 1 2 2 1 2 2 1 1 1 1 ... > ? On Thu, Aug 25, 2016 at 1:42 PM, <ruipbarradas at sapo.pt> wrote: >> _Maybe sex is a factor and Man its label. Factors are coded >> internally as integers, to see it use >> >> str(sex) >> >> Rui Barradas >> ?_ >> >> _Citando Juan Ceccarelli Arias <jfca283 at gmail.com>:_ >> >>> _Nop. I didn't work. But using the following it does work. >>> table(region[sex=="Men"],type[sex=="Men"])_ >>> _When i use the dta file with stata i declare the condition with >>> sex==1 and not sex=="Man"._ >>> _? _ _On Thu, Aug 25, 2016 at 12:39 PM, <ruipbarradas at sapo.pt> wrote: _ >>>> __Hello, >>>> >>>> Try instead >>>> >>>> table(region[sex==1],type[sex=_=1]) >>>> >>>> To test for equality use == not =. >>>> >>>> Hope this helps, >>>> >>>> Rui Barradas >>>> ?_ >>>> >>>> __Citando Juan Ceccarelli Arias <jfca283 at gmail.com>:__ >>>> >>>>> _?_ >>>>> __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.htmland provide >>>>> commented, minimal, self-contained, reproducible code. _ >>>>> _?_ >>>>> _ _ >>>> >>>> __?__ >>> >>> _ _ >>> _ _ >> >> _?_?
Juan Ceccarelli Arias
2016-Aug-25 19:15 UTC
[R] Importint stata file and using value labels
Mmm...The other option working with R for importing the dta file but obtaining the values and deleting or ignoring the value labels. I think some time ago i did that, but now i can't remember it. On Thu, Aug 25, 2016 at 4:11 PM, <ruipbarradas at sapo.pt> wrote:> So you should do > > table(region[sex=="Hombre"],type[sex=="Hombre"] > > Rui Barradas > > > Citando Juan Ceccarelli Arias <jfca283 at gmail.com>: > > str(sex) >>> >> Factor w/ 2 levels "Hombre","Mujer": 1 2 2 1 2 2 1 1 1 1 ... >> On Thu, Aug 25, 2016 at 1:42 PM, <ruipbarradas at sapo.pt> wrote: >> >>> _Maybe sex is a factor and Man its label. Factors are coded internally >>> as integers, to see it use >>> >>> str(sex) >>> >>> Rui Barradas >>> _ >>> >>> _Citando Juan Ceccarelli Arias <jfca283 at gmail.com>:_ >>> >>> _Nop. I didn't work. But using the following it does work. >>>> table(region[sex=="Men"],type[sex=="Men"])_ >>>> _When i use the dta file with stata i declare the condition with sex==1 >>>> and not sex=="Man"._ >>>> _ _ _On Thu, Aug 25, 2016 at 12:39 PM, <ruipbarradas at sapo.pt> wrote: _ >>>> >>>>> __Hello, >>>>> >>>>> Try instead >>>>> >>>>> table(region[sex==1],type[sex=_=1]) >>>>> >>>>> To test for equality use == not =. >>>>> >>>>> Hope this helps, >>>>> >>>>> Rui Barradas >>>>> _ >>>>> >>>>> __Citando Juan Ceccarelli Arias <jfca283 at gmail.com>:__ >>>>> >>>>> _ _ >>>>>> __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/posti >>>>>> ng-guide.htmland provide commented, minimal, self-contained, >>>>>> reproducible code. _ >>>>>> _ _ >>>>>> _ _ >>>>>> >>>>> >>>>> __ __ >>>>> >>>> >>>> _ _ >>>> _ _ >>>> >>> >>> _ _ >>> >> > > >[[alternative HTML version deleted]]