0

I'm new to tidy evaluation- although some things make sense, I usually just try different combinations of {{}}, !! + quo, sym() etc.

But I can't get is.na() to work? here's an example:

column <- "Sepal.Length"
iris_na <- rbind(iris, rep(NA,5))
iris_na %>%
  subset(is.na(column))
Wojty
  • 59
  • 5
  • 2
    The reason your attempts didn't work is that `subset` isn't a ‘dplyr’ function and performs no tidy evaluation. – Konrad Rudolph Dec 01 '22 at 15:59
  • 1
    With `dplyr`, use `iris_na %>% filter(is.na(.data[[column]]))`. `filter` is the dplyr version of the base R function `subset` – MrFlick Dec 01 '22 at 16:00
  • you can try with this syntax `iris_na[column] %>% subset(is.na(.))` – rral Dec 01 '22 at 16:02

1 Answers1

0

You can simple use get

 iris_na %>%
    subset(is.na(get(column)))
    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
151           NA          NA           NA          NA    <NA>

Also you can use filter instead of subset and get the same result

Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138