Observation deleted due to missingness in R

2019-04-25 11:49发布

问题:

I am busy with a regression model in R and i have about 16 000 observations. One of these observations causes me to get the following error message,

(1 observation deleted due to missingness)

Is there a way in R so that i can identify this one observation?

回答1:

If your data is in a data.frame x, and each row corresponds to an observation, then the way to go about this is to identify complete cases via complete.cases(x). Conversely, to find missing values in an observation, do ! complete.cases(x). To find out which observation contains missing values, do

which(! complete.cases(x))


回答2:

There is MWE as well as a solution in this web page : https://stat.ethz.ch/pipermail/r-help/2010-February/227526.html

which(is.na(variable)) as commented by @PeterDee seems to be indeed the solution



标签: r regression