8

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 to identify this one observation?

jpsmith
  • 11,023
  • 5
  • 15
  • 36
Jason Samuels
  • 951
  • 6
  • 22
  • 40

3 Answers3

12

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))
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • complete.cases worked. to identify the observation. Apparently it pulled the empty row from the csv file that was after the last observation. – Jason Samuels Feb 10 '15 at 13:04
2

1 - Give your model a name like for example MyModel:

MyModel <- glm (......)

2 - Get the deleted observations rank by na.action function:

na.action(MyModel)

Results are duplicated in the display

jpsmith
  • 11,023
  • 5
  • 15
  • 36
Urodoc
  • 21
  • 2
0

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

ClementWalter
  • 4,814
  • 1
  • 32
  • 54