I have a dataset with two columns, in one of them are missing values. I load it using
data <- read_excel("file.xlsx") %>%
select("ID", "Value")
The tibble looks like that
ID | Value |
---|---|
1 | 2 |
NA | 4 |
32 | 1 |
The NAs are recognized as such. However, I use
data["ID"=="NA"] <- NA
to ensure that this is not the problem (R: is.na() does not pick up NA value).
When I try to filter:
data %>%
filter(!is.na(ID))
the whole tibble stays the same, and no row is deleted. So I try
data %>%
mutate(
isna <- is.na(ID)
)
and all isna are FALSE.
Why doesn't recognize dplyr the NAs?
I am grateful for every help!
Welcome to SO! Use this to get NAs mutated and then delete the NAs:
data <- data %>%
mutate(ID = ifelse(ID == "NA",NA,ID)) %>%
filter(!is.na(ID))
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments