0

I have a large chunk of NA data, and I would like to exclude all rows with NA data from my dataset. I tried using

mydata[complete.cases(mydata), ] 

but it didn't work. When I View the dataset, the rows are still there. Note that these missing data are not a conceptual problem. I had given participants the option to report up to 30 y-variable examples, but most chose not to report more than 10; however, the dataset contains 30 row per person, even though it turned out more than half of them are empty!

Any suggestions on how to delete NA rows from my dataset?

Thanks!

psyrgh
  • 31
  • 5
  • 4
    Have you assigned the result of that instruction back to `mydata` or to some other data.frame? Another way is to use function `na.omit`. Also, see argument `na.action`. – Rui Barradas Jul 02 '18 at 15:18
  • 3
    Another option: `mydata – Peter_Evan Jul 02 '18 at 15:21
  • Possible duplicate of [Remove rows with NAs (missing values) in data.frame](https://stackoverflow.com/questions/4862178/remove-rows-with-nas-missing-values-in-data-frame) – Jan Boyer Jul 02 '18 at 16:06
  • When I do na.omit it deletes all my data, so I'm not sure whether I need to give clearer specification?! – psyrgh Jul 02 '18 at 17:16

1 Answers1

0

I figured it out, I had a mistake in my datafile. Otherwise, na.omit worked perfectly!

psyrgh
  • 31
  • 5