[R] Prevent Printing Function's Environment

Abs Spurdle @purdle@@ @ending from gm@il@com
Tue Aug 14 05:16:08 CEST 2018


Hi All

When you print a function constructed within a function, R prints it's
environment.
For example:

> myfunction = function ()
+ {   f = function () NULL
+     attributes (f) = list (class="myfunction", myattribute=1)
+     f
+ }

> myfunction.f = myfunction ()

> myfunction.f
function ()
NULL
<environment: 0x03fcbc30>
attr(,"class")
[1] "myfunction"
attr(,"myattribute")
[1] 1

One way to prevent this is to set the function's environment to the global
environment.
But I was wondering if there's a way to stop R from printing the
environment without changing the environment?


kind regards
Abs

	[[alternative HTML version deleted]]



More information about the R-help mailing list