warn_once('method="loess" is recommended', reset = TRUE)
f <- function() {
warn_once('method="loess" is recommended')
invisible()
}
f() # issues the warning
f() # silent: same text has already been warned about
f() # silent
## Different text, but treated as the same warning because of id
g <- function(n) {
warn_once(paste('n =', n, 'is small'), id = 'small.n')
invisible()
}
g(10) # issues the warning
g(12) # silent
## Make the warning appear again
warn_once(reset = TRUE)
f() # issues the warning again
Run the code above in your browser using DataLab