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