[R] replace elements in a list

Wincent ronggui.huang at gmail.com
Fri Apr 30 05:39:35 CEST 2010


Dear all, I have a list like this:  l <- list(list(a=1,b=NULL), list(a=2,b=2))
I want to find out the elements with value of NULL and replace them with NA.
The actual case has a very long list, so manually find out and replace
them is not an option.
I can use for loop to do this, but I want to know if there is
vectorized way (or other ways) to do it?

Thanks
-- 
Wincent Rong-gui HUANG
Doctoral Candidate
Dept of Public and Social Administration
City University of Hong Kong
http://asrr.r-forge.r-project.org/rghuang.html



More information about the R-help mailing list