Make a function return silently

r, return

Solution

myFunc <- function(x){
  invisible(x*2)
}

> myFunc(4)
> y <-myFunc(4)
> y
[1] 8
> 

Problem

I would like to write an R function that returns silently, like what I get from the `barplot` function for example. I mean that I can store an output in a variable if I do `output = myfunction()`, but this output does not get printed if I just use `myfunction()`.

Original source

Related problems