Re: [Rd] Large discrepancies in the same object being saved to .RData

From: Martin Maechler <>
Date: Mon, 12 Jul 2010 11:48:46 +0200

>>>>> "DM" == Duncan Murdoch <> >>>>> on Sun, 11 Jul 2010 17:25:45 -0400 writes:

    DM> On 11/07/2010 1:30 PM, Prof Brian Ripley wrote:


    >>> On 7/10/2010 10:10 PM, wrote:
    >>>> Well, I have answered one of my questions below. The hidden     >>>> environment is attached to the 'terms' component of v1.

>> Well, not really hidden. A terms component is a formula
>> (see ?terms.object), and a formula has an environment
>> just as a closure does. In neither case does the print()
>> method tell you about it -- but ?formula does.

    DM> I've just changed the default print method for formulas to display the 
    DM> environment if it is not globalenv(), which is the rule used for 
    DM> closures as well.  So now in R-devel:

>> as.formula("y ~ x")

    DM> y ~ x

    DM> as before, but

>> as.formula("y ~ x", env=new.env())
    DM> y ~ x
    DM> <environment: 01f83400>

I see that our print.formula() actually has not truely fulfilled our own rule about print methods:

?print has

 > Description:
 >      ‘print’ prints its argument and returns it _invisibly_ 
 >      ..........

Further, I completely agree that it's good to mention the environment, however, it can be a nuisance when it's part of a larger print(.) method, so I'd like allowing to suppress that and hence I've committed the current

print.formula <- function(x, showEnv = !identical(e, .GlobalEnv), ...) {

    e <- environment(.x <- x) ## return(.) original x     attr(x, ".Environment") <- NULL
    print.default(unclass(x), ...)
    if (showEnv) print(e)

Martin Maechler, ETH Zurich

______________________________________________ mailing list
Received on Mon 12 Jul 2010 - 09:51:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 12 Jul 2010 - 10:40:15 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive