[R] convert a data frame with NULL to a list of integer

kennyPA tao_sf at yahoo.com
Sat Jan 30 01:09:40 CET 2010


I have a data frame with integers mixed with a lot of NULLs, how do I convert
that to multiple lists of integers with zero (to replace NULL)? I tried the
following, and they failed:

> dim(g2)
[1] 25352   173
> class(g2)
[1] "data.frame"
> class(g2[1,])
[1] "data.frame"
> g2[1,30:40]
          30 31 32   33 34 35 36   37   38   39   40
NM_000014  1 14  1 NULL 27  8 21 NULL NULL NULL NULL
> g3<-as.integer(g2[1,30:40])
> g3
 [1] NA NA NA NA NA NA NA NA NA NA NA
>

thanks a lot!

-Kenny
-- 
View this message in context: http://n4.nabble.com/convert-a-data-frame-with-NULL-to-a-list-of-integer-tp1445595p1445595.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list