[Rd] Problem with defining new method for residuals()

From: ONKELINX, Thierry <Thierry.ONKELINX_at_inbo.be>
Date: Thu, 10 Mar 2011 16:21:12 +0000


Dear all,

I'm writing a package and I would like to reuse the residuals() function. When I use a function which calls the redefined residuals (for my custom class) I get an error (see below). It looks like the wrong method is used. The strange this is, that when it execute the code manually it get no error.

Any suggestions?

Best regards,

Thierry

The entire source code is at svn://scm.r-forge.r-project.org/svnroot/aflp

The code with the error.

> normalise(dummy)

Error in object$na.action : $ operator not defined for this S4 class
> traceback()

5: naresid(object$na.action, object$residuals) at normalise.R#30
4: residuals.default(outliers(data)) at normalise.R#30
3: residuals(outliers(data)) at normalise.R#30
2: nrow(residuals(outliers(data))) at normalise.R#30
1: normalise(dummy)

#This works fine
> data <- dummy
> nrow(residuals(outliers(data)))

[1] 0

NAMESPACE
importFrom(stats, residuals, resid, hclust, princomp) exportPattern(".")

METHODS
setMethod("residuals", signature(object = "AFLP.outlier"),

	function(object, ...){
		object_at_Residual
	}

)

setMethod("resid", signature(object = "AFLP.outlier"),

	function(object, ...){
		object_at_Residual
	}

)

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
Thierry.Onkelinx_at_inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey  



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 10 Mar 2011 - 16:26:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Mar 2011 - 09:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive