Try this: replace(A, sapply(A, is.null), 0)
On Mon, Nov 29, 2010 at 6:50 PM, LCOG1 <jr...@lcog.org> 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 need to convert some list elements of NULL > value to 0s so they mesh with my data frame properly. So for > > A<-list(1,NULL) > > returns > > [[1]] > [1] 1 > > [[2]] > NULL > > Would instead return > > [[1]] > [1] 1 > > [[2]] > [1] 0 > > The nabble posts seem to indicate dealing with NULLs can be tricky so i am > attributing my lack of success to that, mainly so i can live with myself > and > asking the list such a simple question. Sorry again guys. > > JR > -- > View this message in context: > http://r.789695.n4.nabble.com/List-elements-of-NULL-to-value-tp3064384p3064384.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@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.