[Rd] problems with plot.formula

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Wed May 26 15:28:30 CEST 2004


In R-1.8.1, I could work around the problem because the plot.formula
function is directly executable because it is exported from the graphics
package:

         _                   
platform sparc-sun-solaris2.8
arch     sparc               
os       solaris2.8          
system   sparc, solaris2.8   
status   Patched             
major    1                   
minor    8.1                 
year     2004                
month    02                  
day      05                  
language R                   
> methods(plot)
 [1] plot.HoltWinters*   plot.POSIXct        plot.POSIXlt       
 [4] plot.TukeyHSD       plot.acf*           plot.data.frame    
 [7] plot.decomposed.ts* plot.default        plot.dendrogram*   
[10] plot.density        plot.factor         plot.formula       
                                             ^^^^^^^^^^^^
[13] plot.function       plot.hclust*        plot.histogram     
[16] plot.isoreg*        plot.lm             plot.mlm           
[19] plot.ppr*           plot.prcomp*        plot.princomp*     
[22] plot.profile.nls*   plot.spec           plot.spec.coherency
[25] plot.spec.phase     plot.stl*           plot.table         
[28] plot.ts             plot.tskernel*     

    Non-visible functions are asterisked
> plot.function
> plot.function
function (x, from = 0, to = 1, xlim = NULL, ...) 
{
    if (!is.null(xlim)) {
...


While in R-1.9.x the plot.formula function is not exported:

> version
         _                   
platform sparc-sun-solaris2.8
arch     sparc               
os       solaris2.8          
system   sparc, solaris2.8   
status                       
major    1                   
minor    9.0                 
year     2004                
month    04                  
day      12                  
language R                   
> methods(plot)
 [1] plot.Date*          plot.HoltWinters*   plot.POSIXct*      
 [4] plot.POSIXlt*       plot.TukeyHSD       plot.acf*          
 [7] plot.data.frame*    plot.decomposed.ts* plot.default       
[10] plot.dendrogram*    plot.density        plot.ecdf          
[13] plot.factor*        plot.formula*       plot.hclust*       
[16] plot.histogram*     plot.isoreg*        plot.lm            
[19] plot.medpolish*     plot.mlm            plot.ppr*          
[22] plot.prcomp*        plot.princomp*      plot.profile.nls*  
[25] plot.spec           plot.spec.coherency plot.spec.phase    
[28] plot.stepfun        plot.stl*           plot.table*        
[31] plot.ts             plot.tskernel*     

    Non-visible functions are asterisked
> plot.formula
Error: Object "plot.formula" not found



> -----Original Message-----
> From: r-devel-bounces at stat.math.ethz.ch
> [mailto:r-devel-bounces at stat.math.ethz.ch]On Behalf Of Prof 
> Brian Ripley
> Sent: Tuesday, May 25, 2004 3:45 PM
> To: Warnes, Gregory R
> Cc: 'Troels Ring'; R-devel (E-mail)
> Subject: Re: [Rd] problems with plot.formula
> 
> 
> As this happens in exactly the same way in 1.8.1 and 1.9.0, 
> why are you
> blaming `recent changes in R 1.9.x'?  I am baffled as to what 
> you think is
> `recent'.
> 
> On Tue, 25 May 2004, Warnes, Gregory R wrote:
> 
> > 
> > With the recent changes in R 1.9.x, it is now impossible to 
> properly call
> > plot on a formula() where the formula is provided via a named first
> > argument.  On today's R-1.9.1-alpha:
> > 
> > > x <- 1:10
> > > y <- rnorm(x,0.25)
> > > 
> > > plot(x~y)
> > > 
> > > plot(x=x~y)
> > Error in terms.formula(formula, data = data) : 
> > 	argument is not a valid model
> > > 
> > > plot(formula=x~y)
> > Error in plot(formula = x ~ y) : Argument "x" is missing, 
> with no default
> > > 
> > 
> > This occurs because plot.formula is no longer directly callable, 
> 
> It is, via graphics:::plot.formula.

No, actually it is not:

> graphics::plot.formula
Error: 'plot.formula' is not an exported object from 'namespace:graphics'

> 
> > and the
> > first argument to plot.formula() is 'formula' while the 
> first argument to
> > plot() is 'x'.   Consequently one cannot properly pass a named first
> > argument since it will either fail for plot() or for 
> plot.formula().  [I
> > suspect this is one reason why R CMD check complains about 
> S3 methods that
> > don't match the call of the base method.]
> > 
> > This is much of a problem in interactive use, but it does 
> cause problems in
> > functions, like my gregmisc::overplot(), which use the 
> standard idiom
> > 
> >     m <- match.call()
> >     m[[1]] <- as.name('plot')
> >     eval(m, parent.frame() )
> 
> Not a standard idiom for a generic with a formula method, and 
> I think you 
> really should be dispatching to the method here.
> 

The problem is that plot.formula is not exported, so I cannot dispatch
directly to it.  (This is what I did previously).

-Greg

> [...]
> 
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
> 
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
> 


LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}



More information about the R-devel mailing list