[R] data.frame with NA
Pietro
freerisk3 at gmail.com
Mon Mar 18 19:57:10 CET 2013
Yes, it's true Berend!
What i do is simply use read.xlsx function
db <- read.xlsx2("c:/mydb.xlsx",1,as.data.frame=T)
This is excel file i use:
http://dl.dropbox.com/u/102669/mydb.xlsx
I can't find a way to import as numeric.
My objective is to be able to work (in R) with my NA's
At 18.46 18/03/2013, Berend Hasselman wrote:
>On 18-03-2013, at 16:49, Pete <freerisk3 at gmail.com> wrote:
>
> >
> > I have this little data.frame
> >
> > http://dl.dropbox.com/u/102669/nanotna.rdata
> >
> > Two column contains NA, so the best thing to do is use na.locf
> function (with
> > fromLast = T)
> >
> > But locf function doesn't work because NA in my data.frame are
> not recognized as
> > real NA.
> >
> > Is there a way to substitute fake NA with real NA? In this case
> na.locf function
> > should work
> >
>
>Your data are all characters. Do
>
>str(db)
>
>to see that. What is probably supposed to be numeric is also character,
>Somehow you have managed to read in data that R thinks is all chr.
>Your NA are "NA" in reality: a character string "NA".
>
>You will have to review the method you used to get the data into R.
>And make sure that what you want to be numeric is indeed numeric.
>Then you can start to think about doing something about the NA's.
>
>Berend
More information about the R-help
mailing list