Skip to content
Prev 86437 / 398513 Next

lattice: calling functions

On 2/14/06, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
Although this does seem to be how xyplot works, I think it indicates
there is a problem with it.

The help file for xyplot indicates that for the xyplot formula method
the default
environment is the caller environment whereas it ought to be the environment
of the formula:

    data: For the 'formula' method, a data frame containing values for
          any variables in the formula, as well as 'groups' and
          'subset' if applicable.  By default the environment where the
          function was called from is used.

For example, if we replace xyplot with lm it does work as expected:

   fun1 <- function( x=1:5, y=1:5, ... ) fun2( y ~ x, ... )
   fun2 <- function( ... ) lm( ... )
   fun1()