Suppress Warning Message in RStudio Console in R (2 Examples)
This page demonstrates how to remove warning message from the RStudio console output in the R programming language.
Example 1: Specify Code with Warning Message in R
mean("x") # Produce warning message # [1] NA # Warning message: # In mean.default("x") : argument is not numeric or logical: returning NA |
mean("x") # Produce warning message # [1] NA # Warning message: # In mean.default("x") : argument is not numeric or logical: returning NA
Example 2: Suppress Warnings Using suppressWarnings() Function
suppressWarnings(mean("x")) # Do not print warning message # [1] NA |
suppressWarnings(mean("x")) # Do not print warning message # [1] NA