You seem to have two types of missing data, some marked NA
(which you still consider "complete") and some marked ""
(which you want to omit).
The R convention is opposite from yours - rows with NA
are not considered complete, but the empty string ""
is perfectly valid data. I would recommend you match R's convention while using R - replace the NA
values in your data frame with a string (maybe "missing"
, or "not applicable"
), and replace the empty strings in your data with NA
since you consider them missing. Then complete.cases
will work perfectly for you as suggested in the comments, df2 <- complete.cases(df1)
You can use the replace
function to make these changes to your data column. If your data column is a factor
, you could may instead edit the levels (or just convert it to character
and use the replace
function). If you share your data reproducibly with dput()
(see here for details) I'll be happy to show some more explicit code, but as-is I'm not sure of the structure and underlying classes in your data.