[R] Deleting NA in list()

Dong-hyun Oh oh.dongh at gmail.com
Fri Aug 22 20:41:10 CEST 2008


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: oh.dongh at gmail.com
cel: +46 73 563 45 22



More information about the R-help mailing list