I try extract rows by values.
col1 <- c("A", "B", "C", NA)
df <- data.frame(col1)
df$col1[col1 == "A"]
The result in console is
> df$col1[col1 == "A"]
[1] "A" NA
But of course I only want "A". How to avoid R selecting NA values? By the way I think this behavior is pretty dangerous as many would run into this trap e.g. replacing values, subsetting, etc.