Reputation: 3377
I have tried expressions with suppressMessages(expr), suppressWarnings(expr), but they keep outputting messages.
eg:
suppressWarnings(ksvm(y~., data=data, type='C-svc', cross=5, kernel=kernel))
keeps generating this message.
Setting default kernel parameters
How do I suppress messages from libraries? Is there a way to do this globally?
Have tried:
{r messages=FALSE, warnings=FALSE}
Upvotes: 4
Views: 15197
Reputation: 21
You can pass an empty list to the kpar argument.
Like ksvm(y~., data=data, type='C-svc', cross=5, kernel=kernel, kpar = list())
Upvotes: 2
Reputation: 9656
Here is the link to the line where the output is generated: https://github.com/cran/kernlab/blob/master/R/ksvm.R#L88
Looking at that we see that the message is displayed with cat()
not with message()
. suppressMessages()
does not suppress the cat output.
There are multiple ways to get rid of the cat
output. One is to capture the message and then hide it like so:
invisible(capture.output(ksvm(...)))
Upvotes: 12
Reputation: 5201
If it does not say that it is a warning, you should use suppressMessages
. Try putting the function call in braces:
suppressMessages({ksvm(y~., data=data, type='C-svc', cross=5, kernel=kernel)})
Upvotes: 4