How to remove NaN in large list

不想你离开。 提交于 2019-12-12 04:01:58

问题


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!


回答1:


Try

 MyList <- na.omit(My.List)



回答2:


You can use sapply to find the NaNs

> x <- list(1, NaN, 3)
> 
> x[!sapply(x, is.nan)]
[[1]]
[1] 1

[[2]]
[1] 3


来源:https://stackoverflow.com/questions/44231564/how-to-remove-nan-in-large-list

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!