Re: [R] List elements of NULL to value

2010-11-29 Thread ROLL Josh F
: 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

Re: [R] List elements of NULL to value

2010-11-29 Thread Henrique Dallazuanna
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

Re: [R] List elements of NULL to value

2010-11-29 Thread Phil Spector
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