I saw online with many similar guides as the above, but they use the deprecated functions such as select_if()
or where()
.
What is the updated way to remove all columns with any NA values? I tried some with select(across())
or select(if_any())
, but I think I'm missing the nuance.
df = data.frame(abc = c(1, 2, 3),
def = c(4, 5, NA),
ghi = c(NA, NA, NA))
# DOES NOT WORK -- tells me if_any needs to be in a dplyr verb...
df |>
select(if_any(colSums(is.na(.) > 0)))