[英]R: Remove rows with less than 20 non-“NA” values
How can I remove all rows (from a data frame) that contains less than 20 non-"NA" values? 如何删除包含少于20个非“ NA”值的所有行(从数据框中)? I did try to look up a solution and tried different things, but I am not sure how to go about this. 我确实尝试查找解决方案并尝试了不同的方法,但是我不确定该如何进行。
(I apologize for not adding an example table, but I feel like its not really needed here) (我很抱歉没有添加示例表,但是我觉得这里并不需要它)
Whether you have pure numerical class or multiple classes across columns of your data frame dat
, this will work. 无论您是在数据框架dat
各个列中使用纯数字类还是多个类,这都将起作用。
IndexMat <- sapply(dat, is.na)
subset(dat, rowSums(!IndexMat) > 20) ## or maybe `>=`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.