[R] S4 classes and debugging - Is there a summary?

Joris Meys jorismeys at gmail.com
Fri Jul 2 14:45:08 CEST 2010


Correction: trace off course works when specifying the signature. so eg:

trace(xyValues,tracer=browser,signature=c(object="RasterLayer", xy="matrix"))
allows me to browse through the function. Should have specified the
signature, I overlooked that. Still, if there's a manual on S4 that
anybody likes to mention, please go ahead. I find bits and pieces on
the internet, but haven't found an overview yet dealing with all
peculiarities of these classes.

Cheers
Joris

On Fri, Jul 2, 2010 at 2:05 PM, Joris Meys <jorismeys at gmail.com> wrote:
> Dear all,
>
> I'm getting more and more frustrated with the whole S4 thing and I'm
> looking for a more advanced summary on how to deal with them. Often I
> get error messages that don't make sense at all, or the code is not
> doing what I think it would do. Far too often inspecting the code
> requires me to go to the source, which doesn't really help in easily
> finding the bit of code you're interested in.
>
> Getting the code with getAnywhere() doesn't always work. Debug()
> doesn't work. Using trace() and browser() is not an option, as I can't
> find the correct method.
>
> eg :
> library(raster)
>> getAnywhere(xyValues)
> A single object matching ‘xyValues’ was found
> It was found in the following places
>  package:raster
>  namespace:raster
> with value
>
> standardGeneric for "xyValues" defined from package "raster"
>
> function (object, xy, ...)
> standardGeneric("xyValues")
> <environment: 0x04daf14c>
> Methods may be defined for arguments: object, xy
> Use  showMethods("xyValues")  for currently available ones.
>> showMethods("xyValues")
> Function: xyValues (package raster)
> object="Raster", xy="data.frame"
> object="Raster", xy="SpatialPoints"
> object="Raster", xy="vector"
> object="RasterLayer", xy="matrix"
> object="RasterStackBrick", xy="matrix"
>
> And now...?
>
> Is there an overview that actually explains how you get the
> information you're looking for without strolling through the complete
> source? Sorry if I sound frustrated, but this is costing me huge
> amounts of time, to that extent that I rather write a custom function
> than use one in an S4 package if I'm not absolutely sure about what it
> does and how it achieves it.
>
> Cheers
> Joris
>
>
> --
> Joris Meys
> Statistical consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> tel : +32 9 264 59 87
> Joris.Meys at Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php



More information about the R-help mailing list