How to avoid warning when introducing NAs by coercion July 19, 2022 by Tarik Use suppressWarnings(): suppressWarnings(as.numeric(c("1", "2", "X"))) [1] 1 2 NA This suppresses warnings.