: Monday, November 29, 2010 12:58 PM
To: ROLL Josh F
Cc: r-help@r-project.org
Subject: Re: [R] List elements of NULL to value
Does
A = lapply(A,function(x)if is.null(x) 0 else x) or
for(i in 1:length(A))if(is.null(A[[i]]))A[i] = 0
do what you want
Try this:
replace(A, sapply(A, is.null), 0)
On Mon, Nov 29, 2010 at 6:50 PM, LCOG1 wrote:
>
> Hi everyone,
>I am posting this because i know its easy and i cant for the life of me
> figure out how to do it though i have tried and through a ridiculously
> complex loop made it happen. I ne
Does
A = lapply(A,function(x)if is.null(x) 0 else x)
or
for(i in 1:length(A))if(is.null(A[[i]]))A[i] = 0
do what you want?
- Phil Spector
Statistical Computing Facility
Hi everyone,
I am posting this because i know its easy and i cant for the life of me
figure out how to do it though i have tried and through a ridiculously
complex loop made it happen. I need to convert some list elements of NULL
value to 0s so they mesh with my data frame properly. So for
4 matches
Mail list logo