[R] Importint stata file and using value labels

Juan Ceccarelli Arias jfca283 at gmail.com
Fri Aug 26 17:05:21 CEST 2016


Yep. Im a bit stalled.
I can't find the option to import only the values and drop the value labels
from the dta file.
Im quite sure R can do that. Then i'd only used the values and i'd rely on
my memory.
It isn't a bad alternative.


On Fri, Aug 26, 2016 at 4:11 AM, PIKAL Petr <petr.pikal at precheza.cz> wrote:

> Hi
>
> You can use
>
> as.numeric(sex)
>
> to get numeric values for factor variable. This is sometimes handy for
> plotting.
>
> However if you throw away labels how do you know what naumber belongs to
> which factor level?
>
> Cheers
> Petr
>
> > -----Original Message-----
> > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Juan
> > Ceccarelli Arias
> > Sent: Thursday, August 25, 2016 9:15 PM
> > To: ruipbarradas at sapo.pt
> > Cc: r-help at r-project.org
> > Subject: Re: [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]]
> >
> > ______________________________________________
> > 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.
>
> ________________________________
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
> neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie
> vymažte ze svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email
> jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi
> či zpožděním přenosu e-mailu.
>
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
> smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout;
> Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany
> příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve
> výslovným dosažením shody na všech jejích náležitostech.
> - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za
> společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn
> nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto
> emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich
> existence je adresátovi či osobě jím zastoupené známá.
>
> This e-mail and any documents attached to it may be confidential and are
> intended only for its intended recipients.
> If you received this e-mail by mistake, please immediately inform its
> sender. Delete the contents of this e-mail with all attachments and its
> copies from your system.
> If you are not the intended recipient of this e-mail, you are not
> authorized to use, disseminate, copy or disclose this e-mail in any manner.
> The sender of this e-mail shall not be liable for any possible damage
> caused by modifications of the e-mail or by delay with transfer of the
> email.
>
> In case that this e-mail forms part of business dealings:
> - the sender reserves the right to end negotiations about entering into a
> contract in any time, for any reason, and without stating any reasoning.
> - if the e-mail contains an offer, the recipient is entitled to
> immediately accept such offer; The sender of this e-mail (offer) excludes
> any acceptance of the offer on the part of the recipient containing any
> amendment or variation.
> - the sender insists on that the respective contract is concluded only
> upon an express mutual agreement on all its aspects.
> - the sender of this e-mail informs that he/she is not authorized to enter
> into any contracts on behalf of the company except for cases in which
> he/she is expressly authorized to do so in writing, and such authorization
> or power of attorney is submitted to the recipient or the person
> represented by the recipient, or the existence of such authorization is
> known to the recipient of the person represented by the recipient.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list