I want to replace print()/cat() by message()/warning() as I want it to be suppressed.
However, my code looks quite nested print()/cat() and used print()/cat() multiple times.
I wonder if there is an easier way to fix this problem one-off.
Instead of do packageStartupMessage() & suppressPackageStartupMessages() for each time I used cat() and print()
Also, I am not quite sure, should I just replace print()/cat() directly without affect setMethod() and other functions.
Also, I also get advice about, but how can I used that in my situation?
if(verbose)cat(..) (or maybe stop()) if you really have to write text to the console.
(except for print, summary, interactive functions)
this is my code.
setMethod("print", "ga", function(x, ...) str(x))
setMethod(
"show", "ga",
function(object) {
cat("An object of class \"ga\"\n")
cat("\nCall:\n", deparse(object@call), "\n\n", sep = "")
cat("Available slots:\n")
print(slotNames(object))
}
)
... ...
if (x$type == "real-valued") {
cat(paste("Search domain = \n"))
print(x$domain, digits = digits)
}