According to the R Language Definition (version 3.0.2),
The value returned by a loop statement statement is always NULL and is returned invisibly.
What does it mean for a value to be returned invisibly?
According to the R Language Definition (version 3.0.2),
The value returned by a loop statement statement is always NULL and is returned invisibly.
What does it mean for a value to be returned invisibly?
All functions must return something. invisible
means the return value isn't visible to the user. Consider the simple function below:
f <- function(){
x <- 2
return( x )
}
# Returns 2..
> f()
[1] 2
# Returns 2 but you can't see it
f <- function(){
x <- 2
return( invisible(x) )
}
> f()
>
# But it is still returned...
str(f())
#num 2
You can see the return value of a for
loop like so for example...
str( for( i in 1:3 ){} )
# NULL
Even invisible
itself must return something...
str( invisible() )
# NULL