lt[!is.na(lt)] is a rather obvious way...
On Fri, Aug 22, 2008 at 9:41 PM, Dong-hyun Oh <[EMAIL PROTECTED]> wrote: > Dear useRs, > > I would like to know the way of deleting NA in list(). > > Following is a example. > > lt <- list(a = 1:3, b = NA, c = letters[1:3], d = NA) > > for(i in length(lt):1) { > if(is.na(lt[[i]])) lt[[i]] <- NULL > } > > How to simplify for() loop by using (l)apply family? > > Thank you in advance. > > > > > ========================================================= > Dong-hyun Oh > Center of Excellence for Science and Innovation Studies > Royal Institute or Technology, Sweden > e-mail: [EMAIL PROTECTED] > cel: +46 73 563 45 22 > > ______________________________________________ > 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. > [[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.