Columns of DataFrame in R Programming Language can have empty values represented by NA. In this article, we are going to see how to remove rows with NA in one column. We will see various approaches to remove rows with NA values.
Data in use:
- Create a data frame
- Select the column on the basis of which rows are to be removed
- Traverse the column searching for na values
- Select rows
- Delete such rows using a specific method
Method 1: Using drop_na()
drop_na() Drops rows having values equal to NA. To use this approach we need to use “tidyr” library, which can be installed.
Method 2: Using is.na()
is.na() function first looks for na values in a column and then discards such rows.
is.na(name of the column)
Method 3:Using complete.cases()
This function functions similar to the above two methods
complete.cases(name of the column)