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
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
On 07/02/2010 05:05 AM, Joris Meys 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...?selectMethod(xyValues, c('RasterLayer', 'matrix')) would be my choice.> 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.I don't really have the right experience, but Chamber's 2008 Software for Data Analysis... and Gentleman's 2008 R Programming for Bioinformatics... books would be where I'd start. ?Methods and ?Classes are I think under-used. Martin> > Cheers > Joris > >-- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793