invisible(x=NULL)
passAlongInvisibility(expr)
invisible
reaches back 2 frames
and sets a special flag,
.Auto.print, to
FALSE
.
This has the effect of preventing automatic printing
if the function calling
invisible
was called from
the top level
since
.Auto.print
in frame 1
is set to
FALSE
.
If a function wants to return an invisible value
if the function
itcalls does so,
it can use
passAlongInvisibility(func(x))
,
as in the
checking
example below.
function(x, y=log(x)) { plot(x,y) invisible(list(x,y)) # return a value invisibly } histPositive <- function(x,...) { passAlongInvisibility(hist(x[x>0],...)) # mimic hist's invisibility } histPositive((-5):5, plot=F) # visible result histPositive((-5):5, plot=T) # invisible result