How to remove missing line?

Question:

I have a database that has some missings (NA's), but in only one variable (a column), and I need to remove the entire row that has the missing.

Answer:

To remove rows with no data in R, you must use the complete.cases() function.

For example in a dataset {x}:

y <- x[complete.cases(x),]
str(y)

The complete.cases(x) is a logical vector that will return TRUE for rows with data and FALSE for rows without data.

Scroll to Top