Detailed close-up of a hand pointing at colorful charts with a blue pen on wooden surface.

Easy methods to Choose Rows with NA Values in R

Posted on
banner 336x280

You’ll utility please see modes to make a choice rows with NA values in R:

Mode 1: Choose Rows with NA Values in Any Column

banner 468x60
df[!complete.cases(df), ]

Mode 2: Choose Rows with NA Values in Explicit Column

df[is.na(df$my_column), ]

Refer to examples display learn how to utility each and every mode with please see information body in R:

#build information body
df <- information.body(issues=c(4, NA, 10, 14, 15, NA, 20, 22),
                 rebounds=c(NA, 3, 3, 7, 6, 8, 14, 10),
                 assists=c(NA, 9, 4, 4, 3, 7, 10, 11))

#view information body
df

  issues rebounds assists
1      4       NA      NA
2     NA        3       9
3     10        3       4
4     14        7       4
5     15        6       3
6     NA        8       7
7     20       14      10
8     22       10      11

Instance 1: Choose Rows with NA Values in Any Column

Refer to code displays how to make a choice rows with NA values in any column of the information body in R:

#make a selection rows with NA values in any column
na_rows <- df[!complete.cases(df), ]

#view effects
na_rows

  issues rebounds assists
1      4       NA      NA
2     NA        3       9
6     NA        8       7

Realize that the rows with NA values in any column are decided on.

Instance 2: Choose Rows with NA Values in Explicit Column

Refer to code displays how to make a choice rows with NA values in a selected column of the information body in R:

#make a selection rows with NA values within the issues column
na_rows <- df[is.na(df$points), ]

#view effects
na_rows

  issues rebounds assists
2     NA        3       9
6     NA        8       7

Realize that simplest the rows with NA values within the issues column are decided on.

Alternative Assets

Refer to tutorials give an explanation for learn how to carry out alternative ordinary duties in R:

Easy methods to Virtue entire.circumstances in R
Easy methods to Virtue na.put out of your mind in R
Easy methods to Take away Uninhabited Rows from Information Body in R

banner 336x280

Leave a Reply

Your email address will not be published. Required fields are marked *