search for: callnextmethod

Displaying 20 results from an estimated 97 matches for "callnextmethod".

2012 Aug 03
1
Interaction between callNextMethod() and selectMethod()
Hi, Strange things happen. Here is a simple example: > setClass("A", contains="integer") > setMethod("as.matrix", "A", function(x, ...) t(callNextMethod())) Creating a generic function for ?as.matrix? from package ?base? in the global environment [1] "as.matrix" > a <- new("A", 1:3) > as.matrix(a) [,1] [,2] [,3] [1,] 1 2 3 Everything fine so far. But: > selectMethod("as.matr...
2006 May 11
2
S4 initialize methods, unexpected recursive callNextMethod
Hi, Given a simple three class hierarchy: A <-- B <-- C I want to define an initialize method for each class such that when I call new("C", x=5), the initialize methods for A and B are used to incrementally build the object. When I do what seems obvious to me using callNextMethod, I get an infinite recursion. An example follows... setClass("A", representation(a="numeric")) setClass("B", representation(b="numeric"), contains="A") setClass("C", representation(c="numeric"), contains="B") setMeth...
2011 Dec 09
1
'callNextMethod' in a '[<-' function does not work ?
Hi the list, I try to use callNextMethod in a setteur ([<-) but it does not work. Any raison ? Any other option ? --- 8< ------------------ ### Class B0 ### setClass("B0" , representation(b0 = "numeric")) setReplaceMethod("[","B0",function(x,i,j,value){x at b0 <- -value}) a <- new(&qu...
2009 Jun 05
2
S4: When is validObject issued? (or why S4 is killing me:( ..
...ked in S4? Documentation is silent:(. Here is a small example: setClass("test1",representation(a="numeric")) setMethod("initialize","test1", function(.Object,...){ a<-runif(1) ## here slot "a" is initialized ## callNextMethod(.Object,a=a,...) }) > new("test1") An object of class "test1" Slot "a": [1] 0.755 #next new subclass is created with an additional slot "b": setClass("test2",contains="test1",representation(b="numeric")...
2010 Jul 20
1
Extract callNextMethod "array" calls "matrix"?
I have a class that extends array and my method for "[" stops with an error: > setClass("A", contains="array") [1] "A" > setMethod("[", "A", function(x, i, j, ..., drop = TRUE) new("A", callNextMethod())) [1] "[" > a<-new("A",array(1:12,c(4,3,1))) > a An object of class "A" , , 1 [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 11 [4,] 4 8 12 > a[1:2,2:3,1] Error in x[i = i, j = j, NULL, ...] : incorrect number of di...
2005 Apr 20
1
callNextMethod()
...one but adds extra slots. I have a corresponding generic function for which I have described methods for each of these classes in a signature with one other variable. There are also some ad hoc variable outside the signature which have different default values for each class. Each method calls callNextMethod() to populate the slots which it has in common with the previous class and then some additional code to populate the new slots in the class. Before writing each new method the selectMethod() function correctly identifies the method which I would like to call from the callNextMethod() function....
2003 May 21
1
callNextMethod
...sentation(b0 = "numeric")) setClass("B1", representation("B0", b1 = "character")) setClass("B2", representation("B1", b2 = "logical")) f <- function(x) class(x) setMethod("f", "B0", function(x) c(x at b0, callNextMethod())) setMethod("f", "B1", function(x) c(x at b1,x at b0*x at b0,callNextMethod())) setMethod("f", "B2", function(x) c(x at b2, callNextMethod())) b0 <- new("B0", b0 = 3) b1 <- new("B1", b1 = "deux", b0 = 2) b2 <- new(&qu...
2010 Jan 13
1
bug in callNextMethod (PR#14185)
Hi, there seems to be a possible bug in callNextMethod in conjunction with the [-operator. Relevant info, minimal example and sessionInfo follow below: ############################### setClass("foo", representation = representation(a = "numeric")) setClass("bar", contains = "foo") setMethod( f = &quo...
2008 Mar 20
1
setMethod for "["
...epresentation(x="matrix", y="character")) and I would like to use the method *"["* for a *myClass* objects (but changing the default *drop* argument from TRUE to FALSE): setMethod("[","myClass", function(x,i,j,...,drop=FALSE) { x <- x@x callNextMethod() x<-as.myClass(x) } ) suppose that *as.myClass* method has been already defined. Actually, all I want is to pass all the arguments to *"["* method for *matrix*, except changing the default behaviour for *drop*. When I execute: > test<-new("myClass",x=cbind(1:3,4:...
2007 Dec 24
0
callNextMethod() with builtin group methods fails to create proper environment
Hi all, After all these years, I am finally porting some R-2.3.1-based S4 object code to R-2.6.1, dealing with all the S4 object system changes that came in R-2.4.0. I've run across what appears to be some sort of ommission in the implementation of callNextMethod() when used with primitives having group generic methods. In a stock R-2.6.1 patched (happens to be running on AMD64/RHEL 4, but that shouldn't matter), the following occurs: R version 2.6.1 Patched (2007-12-03 r43584) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-90005...
2012 Nov 06
2
Question on callNextMethod
I don't understand why I get the following results. I define two classes 'Base' and 'Derived', the latter of which 'contains' the first. I then define a generic method 'test' and overload it for each of these classes. I call 'callNextMethod()' in the overload for Derived. From the output, it appears that the overload for Base gets called twice. Why is this? Test code follows: setClass('Base') setClass('Derived', contains='Base') setGeneric('test', function(x) standardGeneric('test')) setMet...
2010 Sep 23
1
strange behaviour of callNextMethod in S4 methods
Hello, I experienced a strange behaviour of callNextMethod when used in either initialize or any other S4 function method definition. Help says callNextMethod calls the next inherited method for the current function from where it is called with the same actual (non missing) arguments. This is OK. The problem appears when some formal arguments (in parti...
2007 Mar 04
1
Problem using callNextMethod() in S4
Dear all, Maybe, I am doing something wrong, but using R-2.5.0 on my Intel-Mac, I have problems using function callNextMethod() in method initialize. I am loading the following code as file "testS4.R": setClass("baseClass", representation(myname = "character", mydir = "character", "VIRTUAL"), prototype(myname = "",...
2008 Sep 09
0
Defining an alias for a generic function and callNextMethod() strange behaviour
...c and methods (simplified version): setGeneric("foo", signature="x", function(x, y=NA) standardGeneric("foo")) setMethod("foo", "ANY", function(x, y=NA) list(x, y)) setMethod("foo", "character", function(x, y=NA) unlist(callNextMethod())) > foo(5) [[1]] [1] 5 [[2]] [1] NA > foo("a") [1] "a" NA And I want to define a temporary alias for foo() for backward compatibility with some existing code: oldfoo <- function(...) { .Deprecated("foo"); foo(...) } > oldf...
2005 Aug 05
1
S4 generating function
...t;Superclass") setMethod("initialize", signature(.Object = "Subclass"), function(.Object, ...) { cat("initialize (Subclass)", "\n") cat("\t... =");str(list(...));cat("\n") callNextMethod(.Object, ...) }) Subclass <- function(id = "") { new("Subclass", id = id) } cat("*** Create class using new() ***\n") str(new("Subclass", id = "test1")) cat("*** Create class using generating function ***\n") str(Subcla...
2017 Apr 20
2
Problems with S4 methods dispatching on `...` (aka dotsMethods)
Hi all, I recently encountered some unexpected behavior with S4 generics dispatching on `...`, which I described in http://stackoverflow.com/questions/43499203/use-callnextmethod-with-dotsmethods TL;DR: `callNextMethod()` doesn't work in methods dispatching on `...`, and arguments of such methods are resolved differently than the arguments of methods dispatching on formal arguments. Could this indicate a potential problem with the implementation of the `...` dispatch?...
2017 Apr 25
3
Problems with S4 methods dispatching on `...` (aka dotsMethods)
...39;s also a (passing) regression test in R. Are you sure you're using a new enough R-devel? On Tue, Apr 25, 2017 at 2:34 AM, Andrzej Ole? <andrzej.oles at gmail.com> wrote: > Hi Michael, > > thanks again for your patch! I've tested it and I'm happy to confirm that > `callNextMethod()` works with methods dispatching on `...`. > > However, the second issue I reported still seems to be unresolved. Consider > the following toy example, where the `f()` calls differ in result depending > on whether the dispatch happens on a formal argument or the `...` argument. > &g...
2017 Apr 21
2
Problems with S4 methods dispatching on `...` (aka dotsMethods)
..., Apr 20, 2017 at 8:30 AM, Andrzej Ole? <andrzej.oles at gmail.com> > wrote: > > Hi all, > > > > I recently encountered some unexpected behavior with S4 generics > > dispatching on `...`, which I described in > > http://stackoverflow.com/questions/43499203/use-callnextmethod-with- > dotsmethods > > > > TL;DR: `callNextMethod()` doesn't work in methods dispatching on `...`, > and > > arguments of such methods are resolved differently than the arguments of > > methods dispatching on formal arguments. > > > > Could this indica...
2014 Feb 11
1
getting environment from "top" promise
...mpg > cutoff)) } a <- new("A", df=mtcars) dropLowMpg(a) The above works just fine, because we figured out that we need to evaluate in the grand-parent frame to avoid the frame of the generic call. But now let's assume A has a subclass B, and subset,B delegates to subset,A via callNextMethod(). The call stack is different, and our assumption is invalid. setClass("B", representation(nrow="integer"), contains="A") setMethod("subset", "B", function(x, ...) { ans <- callNextMethod() ans@nrow <- nrow(ans@df) ans }) b <- new(&...
2017 Aug 07
1
Problems with S4 methods dispatching on `...` (aka dotsMethods)
I ported that over. On Tue, Aug 1, 2017 at 5:50 AM, Andrzej Ole? <andrzej.oles at gmail.com> wrote: > Thank you Michael for updating the 3.4 branch, the `callNextMethod()` now > works for `...` methods as expected. However, I'm still missing your other > patch fixing the handling of arguments in `...` methods. It would be really > great if this bugfix could be integrated into the 3.4 branch as well, such > that the following code doesn't result...