[R] bad STATA dataset import, how to change value labels

Edoardo Prestianni edoardo.prestianni at gmail.com
Mon Dec 8 02:48:10 CET 2014


>> Excuse the inaccuracy, the warning is "value label missing". the same
variable is considered as factor (w/ values ranging from a to b) in one
dataset, as int in another. I want it to be a factor in both.

> So, you are importing two different Stata formatted files an in only one
of them is the warning being emitted?

Yes. But the variable is the very same variable, it's an
administrative/postal code given to each province of the country I'm
studying.
Factor have mode integer, but does that that "int" imply also "nominal" as
well? I thought I needed a "factor" for that.


One dataset emits a warning and shows the variable as "int". The other
seems fine, factor w/ values ranging from a to b,  but when I use the the
str(data$var) function, the value shown are weird, like 1011000, 10120000
... instead of being four-digit numbers.


>> Post the results of dput(head( dfrm[ , "varname"]))
>My intent was for you to substitute the name of your dataframe for the
token `dfrm`.

I apologize. The output is:

__________

[1] 1 1 1 1 1 1

__________


Thanks for your time







2014-12-07 19:15 GMT+01:00 David Winsemius <dwinsemius at comcast.net>:

>
> On Dec 6, 2014, at 6:37 PM, Edoardo Prestianni wrote:
>
> > Excuse the inaccuracy, the warning is "value label missing". the same
> variable is considered as factor (w/ values ranging from a to b) in one
> dataset, as int in another. I want it to be a factor in both.
>
> So, you are importing two different Stata formatted files an in only one
> of them is the warning being emitted?
>
> >
> > I think I am missing a package, the output is.
> >
> > Error in head(dfrm[, "variable"]) : object 'dfrm' not found
>
> My intent was for you to substitute the name of your dataframe for the
> token `dfrm`.
>
> head(yourDataObject[, "yourVariableNameInQuotes"])
>
> --
> David.
>
> >
> >
> > 2014-12-07 3:14 GMT+01:00 David Winsemius <dwinsemius at comcast.net>:
> >
> > On Dec 6, 2014, at 3:54 PM, Edoardo Prestianni wrote:
> >
> > > hello,
> > >
> > > I have imported a couple of .dta datasets, but a variable, instead of
> being
> > > labeled as factor (w/ values ranging from a to b) is labeled as
> integer.
> > >
> > > How can I fix this? I am sorry if it is a rookie question but I don't
> find
> > > the command googling.
> >
> > What "command"?
> >
> > The word "labeled" is not an R term unless on is talking about the
> labels of factor variables in which case there is no problem. Factors have
> mode integer.
> >
> > Post the results of dput(head( dfrm[ , "varname"]))
> >
> > --
> > David.
> >
> >
> > > Thanks everyone for their help,
> > >
> > > --
> > > Edoardo Prestianni
> > >
> > >       [[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.
> >
> > David Winsemius
> > Alameda, CA, USA
> >
> >
> >
> >
> > --
> > Edoardo Prestianni
>
> David Winsemius
> Alameda, CA, USA
>
>


-- 
Edoardo Prestianni

	[[alternative HTML version deleted]]



More information about the R-help mailing list