[R] setMethodReplace.. Help!
John Chambers
jmc at lucent.com
Thu Jan 29 20:27:31 CET 2004
The error message says it: in R, the arguments for the generic function
"[" include i and j; the method definition must include those as well.
Do getGeneric("[") or ?"[" to see the arguments.
As has been said on the R mailing lists in the past, R is generally
compatible with the published books, but not when there is a better
approach. Having the extra arguments allows methods to be based on the
class of the row or column indices.
wolski wrote:
> Hi!
>
> Trying to reproduce some examples from "Programming with Data" page 341.
> Can not reproduce it neither on R1.8.1. nor R1.9.0devel?
>
>
> library(methods)
> setClass("track",representation(x="numeric",y="numeric"))
>
> setMethod("["
> ,"track"
> ,function(x,...,drop=T){
> track(x at x[...],y at y[...])
> }
> )
>
> In method for function "[": Expanding the signature to
> include omitted arguments in definition: i = "missing",
> j = "missing"
> Error in .MakeSignature(new("signature"), def, signature) :
> The names in signature for method (x, , ) don't match function's arguments (x, i, j, drop)
>
> The same....
> setReplaceMethod("[","track"
> ,function(x,...,value)
> {
> x at y[...]=as(value,"numeric")
> }
> )
>
>
> Please Help.
> Eryk.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
--
John M. Chambers jmc at bell-labs.com
Bell Labs, Lucent Technologies office: (908)582-2681
700 Mountain Avenue, Room 2C-282 fax: (908)582-3340
Murray Hill, NJ 07974 web: http://www.cs.bell-labs.com/~jmc
More information about the R-help
mailing list