Using mutate_at to get rid of age values less than 18

I want to get rid of ages less than 18 in my data set by converting them to missing values using mutate_at. I found A way to do it, but I'm certain that there's a more efficient way. Here's what I have:

dataie = dataselected %>%

mutate_at ("RIDAGEYR", na_if, 0) %>%
mutate_at ("RIDAGEYR", na_if, 1) %>%
mutate_at ("RIDAGEYR", na_if, 2) %>%
...
etc, all the way up to 17.

I'm pretty new to RStudio, so any advice is welcome.

I think this might work:

library(tidyverse)

dataie <- dataselected %>%
  mutate(
    ridageyr = case_when(
      ridageyr < 18 ~ NA_integer_,
      TRUE ~ as.numeric()
    ))

Edit: Submitting your question as a reproducible example would help others better answer your question. Welcome to the RStudio Community!