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

Joris Meys jorismeys at gmail.com
Fri Jul 2 14:05:13 CEST 2010


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



More information about the R-help mailing list