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

Example 2: Suppress Warnings Using suppressWarnings() Function

suppressWarnings(mean("x"))        # Do not print warning message
# [1] NA

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top