R- 在四列中的至少一列中选择具有非 NA 值的行 [英] R- Select rows with non-NA values in at least one of the four columns
本文介绍了R- 在四列中的至少一列中选择具有非 NA 值的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这段代码可以正常工作:
I have this code that works fine:
CompleteCoxObs<-temp[is.na(temp[,8])== FALSE | is.na(temp[,9])== FALSE | is.na(temp[,10])== FALSE,];
达到相同结果的更好、更有效的方法是什么?
What is a better and more efficient way to achieve the same result?
推荐答案
你可以试试这个来检查所有的列:
You can try this to check for all the columns:
CompleteCox.df <- temp.df[rowSums(is.na(temp.df)) != ncol(temp.df),]
就你而言:
CompleteCox.df <- temp.df[rowSums(is.na(temp.df[, c(8,9,10)])) != 3,]
这篇关于R- 在四列中的至少一列中选择具有非 NA 值的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文