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

jim holtman jholtman at gmail.com
Sat Jan 30 12:50:28 CET 2010


Exactly how do you want to convert it?  It looks like you have columns
that are not integers, but factors.  Can you provide an 'str' of the
dataframe so that we can see what the structure is.  Can you also
provide an idea of what you want as output; you say a multiple list of
integers, but I am not sure what you are expecting.  If you have
factors, some appear to be character data; how are those to be
handled?  A small subset of the data would be helpful.

On Fri, Jan 29, 2010 at 7:09 PM, kennyPA <tao_sf at yahoo.com> wrote:
>
> 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.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list