[R] Determining whether a function's return value is assigned

Thomas Lumley tlumley at u.washington.edu
Mon Jul 2 16:16:38 CEST 2007


On Sat, 30 Jun 2007, Paul Laub wrote:

> Dear all,
>
> Does R offer a means by which a function can determine
> whether its return value is assigned? I am using R
> 2.4.1 for Windows.

No

> Suppose what I am looking for is called
> "return.value.assigned". Then one might use it like
> this
>
>    myfunction <- function () {
>        # Create bigobject here
>
>        if (return.value.assigned()) {
>            bigobject
>        } else {
>            summary(bigobject)
>        }
>    }

That's what the print() function is for. Write a print() method.

 	-thomas



More information about the R-help mailing list