Consider the following function foo
foo <- function(x) { print(x) message("test message") }
I want to pass the message after the result of the function, so if the result is long, I do not need to scroll up to see if there was an important message (or change my max.print ). The problem is when I want to assign a result without printing the actual result.
Is there a way to print the result of a function followed by a message, but also so that nothing is printed when assigning the result? Ideally, I would like to avoid using print at all.
Desired outcome without assignment -
> foo(5)
The desired result with assignment is
> bar <- suppressMessages(foo(5)) > bar
source share