[R] strange things with eval and parent frames

Martin Maechler maechler at stat.math.ethz.ch
Wed Sep 4 09:37:39 CEST 2002


>>>>> "Mark" == Mark Bravington <Mark.Bravington at csiro.au>
>>>>>     on Wed, 4 Sep 2002 13:19:47 +1000  writes:

	  <.... ((much more)) ....>

    Mark> Incidentally, is there any way of testing whether two
    Mark> environments are identical (e.g. between elements of
    Mark> the list returned by sys.frames())? The operator ==
    Mark> doesn't work, and nor does "all.equal". The only fudge
    Mark> I could devise, was to print them via a
    Mark> textConnection, and compare the text
    Mark> representations... ugh.

"ooaeeh", indeed!

The proper solution is  identical(.,.)  which has been new only since 1.4.0,
(a John Chambers' feature of S4, hence also in newer versions of S-plus,)
e.g.,

      > identical(.GlobalEnv, environment())
      [1] TRUE

identical() has still been underused quite a bit,
probably even in base R code.   In many cases,
	 identical(x,y)	
is now preferable to
         all(x == y)

even when the latter does work.

Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list