Specify class of NA in R (for if_else, dplyr)
you can use NA_real_
if_else(mtcars$cyl > 5, NA_real_, 1)
try the base function
ifelse(mtcars$cyl > 5, NA, 1)
you can use NA_real_
if_else(mtcars$cyl > 5, NA_real_, 1)
try the base function
ifelse(mtcars$cyl > 5, NA, 1)