How to hide warning messages from self-written function in R?

Viewed 7566

I am running an ordinary R script in which I have a self-written function. The function makes use of rm() which often produces warnings I do not want to appear in console output. Any of these solutions:

  1. hiding warnings from rm usage from this particular self-written function,
  2. hiding warnings from all usages of rm (globally for an R session)

would satisfy me.

foo.function <- function(){
  rm(foo.object)
  print("foo")
}

foo.function()
# [1] "foo"
# Warning message:
# In rm(foo.object) : object 'foo.object' not found
1 Answers
Related