invisible(x)
x | any object. If not specified, NULL is assumed. |
1:5 # prints [1] 1 2 3 4 5invisible(1:5) # doesn't print anything
xx <- function(x,y) x+y xx(1,2) # prints [1] 3
xx <- function(x,y) invisible(x+y) xx(1,2) # doesn't print anything
xx <- function(x,y) invisible(x)+invisible(y) xx(1,2) # prints [1] 3 # because the "+" operation clears invisibility
xx <- function(x,y) x<-y xx(1,2) # doesn't print anything # because assignment is invisible
xx <- function(x,y) (x<-y) xx(1,2) # prints [1] 2 # because parentheses around assignment clears invisiblity