I have a dateframe with NA values in one of the columns, I have assigned it to variable with the below code:
missing_weight <- subset(baseball, is.na(weight))
this gave me a set of rows with NA value under weight column.
I am looking to now remove missing_weight from the original dataframe 'baseball' and update the baseball dataframe with no NA value for weight.
CodePudding user response:
Maybe using dplyr::anti_join
will help.
missing_weight <- subset(baseball, is.na(weight))
weight <- dplyr::anti_join(baseball, missing_weight)
CodePudding user response:
We may use
library(dplyr)
baseball %>%
filter(is.na(weight)) %>%
anti_join(baseball, .)