Reputation: 319
I'm trying to remove my NaNs
in a very large list.
Removing NAs
is quite easy with
My.List[!is.na(My.List)]
But using
My.List[!is.nan(My.List)]
is not an implemented method for lists (R-Error).
Can you help me? Thanks!
Upvotes: 0
Views: 5114
Reputation: 9933
You can use sapply
to find the NaN
s
> x <- list(1, NaN, 3)
>
> x[!sapply(x, is.nan)]
[[1]]
[1] 1
[[2]]
[1] 3
Upvotes: 4