Assume I have a list of lists as:
d <- list(matrix(c(1:6),nrow=3,ncol=2),matrix(c(7:12),nrow=3,ncol=2)) e <- list(matrix(c(1:6),nrow=3,ncol=2),matrix(c(7:9,NA,NA,12),nrow=3,ncol=2)) f <- list(d,e) rapply(f, na.omit, how = "replace")
when I use this rapply
function, it just removes the rows that have NA
in them. I want the whole list removed, if any NA
is found there. What I mean is that since we have NA
in list e
, then I want list e
completely gone from list f
. How can I do this?
PS. The real data that I am working with is slightly different than what I replicated here. It is a long list of over 550 lists, which each are 8 x 6
dataframes. Here is a snapshot of how it looks like. I'm not sure if the answer to what I replicated here would be the same for my real data but let's give it a try! (In the real data, some of Bid Yield values are NA
's)
PS2. I can share the data via google drive, if you think the answer is different.
Any helps would be appreciate!
https://stackoverflow.com/questions/66978643/omitting-the-whole-list-if-na-present April 07, 2021 at 10:05AM
没有评论:
发表评论