similar to: callNextMethod() with builtin group methods fails to create proper environment

Displaying 20 results from an estimated 2000 matches similar to: "callNextMethod() with builtin group methods fails to create proper environment"

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 = "[", signature =
2008 Sep 09
0
Defining an alias for a generic function and callNextMethod() strange behaviour
Hi, My package contains the following foo() generic 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]]
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",
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)
2005 Apr 20
1
callNextMethod()
I have built a sequence of eight S4 classes, each of which inherits from the previous 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
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("B0") a at b0 <- 3 a a["b0"] <- 3 a
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 particular, S4 objects) of this function are
2003 May 21
1
callNextMethod
Hi, I don't understand why this code doesn't work (f(b2)): ///////////////// setClass("B0", representation(b0 = "numeric")) setClass("B1", representation("B0", b1 = "character")) setClass("B2", representation("B1", b2 = "logical")) f <- function(x) class(x) setMethod("f", "B0",
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
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"),
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
2009 Jun 05
1
S4: Initialization method called during setClass??
Dear UseRs, A simple class inheritance example: > setClass("test",representation(a="numeric")) > setMethod("initialize","test", function(.Object,x,...){ print("Initialization!!!") callNextMethod(.Object,a=x,...) }) > new("test",x=23) [1] "Initialization!!!" An
2019 Sep 27
0
missing imports not detected by 'R CMD check' (?)
>>>>> Henrik Bengtsson >>>>> on Tue, 24 Sep 2019 11:42:13 -0700 writes [to me (as maintainer of 'Matrix') and allowed me to answer in public] : > I ran into a problem where 'R CMD check' on my in-house package, which > only indirectly depends on 'Matrix', produce errors like: > > [where=<environment: namespace:Matrix>,
2009 Nov 25
1
group generics
I have classes A and B, where B contains A. In the implementation of the group generic for B I would like to use the corresponding group generic for A. Is there a way to do that? I would also appreciate any comments if what I'm trying to do seems like the wrong approach. Here's a stripped down example: setClass("A",
2006 May 10
1
What is callGeneric used for?
I've recently come across two pieces of code using calls to callGeneric() inside the definition of a method. In both cases, it appears to me that the callGeneric call could be replaced with a "real" call to the generic, say foo(x) instead of callGeneric(x) inside method foo. My understanding from the docs is that when called with arguments, it is just like calling the actual
2012 Jul 22
0
callGeneric(...) and lazy evaluation
There seems to be an issue with passing "..." to callGeneric(), because it assumes that the call can be evaluated in the parent frame. Due to lazy evaluation, that is often not going to work for arguments that are simply passed down via "...". Here is an example: setClass("A", contains = "character") setClass("B", contains =
2006 May 09
1
YA S4 method dispatch question
I recently encountered this and was wondering if someone could explain what happened. Basis of question involves what the difference between the calls makes as the end result is the same: > identical(matrix(1:8, nrow = 1), array(1:8, c(1, 8))) TRUE If I run the code below as shown, I get the following: > foo(1:8, 4) foo (vector, numeric) val = 4 foo (matrix, ANY) val = 500 foo
2004 Jun 07
1
Lazy Evaluation?
Hello, I've stumbled upon following problem, when trying to overload the methods for group Math for an S4-class which contains functions as slots. setClass("NumFunction", representation = list(fun = "function")) NumFunction <- function(f) new("NumFunction", fun = f) square <- function(x) x^2 NF <- NumFunction(square)
2009 Jun 05
2
S4: When is validObject issued? (or why S4 is killing me:( ..
Dear UseRs, Does anyone know when exactly the validity is checked 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,...)
2009 Jun 15
1
S4: Bug in group method defenition ("Compare")
Dear UseRs, Setting methods for groups ("compare" in this case) does not work properly. Once one method is set ,redefining it or even removing does not change the behavior: setClass("foo" ,representation(range="numeric") ) #[1] "foo" setMethod("Compare",c(e1="ANY",e2="foo"), function(e1,e2){ browser()