[R-sig-Geo] (no subject)

pir2.jv pir2.jv at wanadoo.fr
Thu Sep 28 16:42:13 CEST 2006


Le 28 sept. 06 à 16:18, Roger Bivand a écrit :

>>>
>>> If you say ls(), do the names of any of the objects begin with plot?
>>
>>> ls(pat="plot")
>> [1] "BBplot"             "Bplot"              "draw.plotmath.cell"
>> [4] "plot"               "plotG"              "plotM"
>> [7] "plotx"              "plotxx"
>>
>> plotx, plotxx, plotG and plotM are functions of mine. Is there a
>> problem ?
>
> The problem is that your local function plot is masking the one which
> understands that "SpatialPolygons" objects have their own method  
> and need
> to be sent there, so yes, at least your local plot is the problem. The
> standard advice if you have a number of functions is to write a  
> package
> with a NAMESPACE, and that will protect you from R not choosing the  
> one
> you intended.
>
Why would be my function plot local ? It is not.
I removed the others

============
 > plot
function (x, y, ...)
{
     if (is.null(attr(x, "class")) && is.function(x)) {
         nms <- names(list(...))
         if (missing(y))
             y <- {
                 if (!"from" %in% nms)
                   0
                 else if (!"to" %in% nms)
                   1
                 else if (!"xlim" %in% nms)
                   NULL
             }
         if ("ylab" %in% nms)
             plot.function(x, y, ...)
         else plot.function(x, y, ylab = paste(deparse(substitute(x)),
             "(x)"), ...)
     }
     else UseMethod("plot")
}
<environment: namespace:graphics>

=============================
>
>

Jacques Vernin




More information about the R-sig-Geo mailing list