similar to: 'callNextMethod' in a '[<-' function does not work ?

Displaying 20 results from an estimated 5000 matches similar to: "'callNextMethod' in a '[<-' function does not work ?"

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",
2009 Oct 27
1
How to reduce key strokes when defining S4 classes?
I feel tedious when I define a S4 class and the methods. For each method, I have to call both setMethod and setGeneric (or both setReplaceMethod and setGeneric). I would like a more compact grammar so that I can reduce the key strokes. I'm wondering if there is a better way available. setClass( Class='A', representation=representation( x='numeric' )
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",
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
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
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 =
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)
2008 Apr 14
3
Doing the right amount of copy for large data frames.
Hi there, Problem :: When one tries to change one or some of the columns of a data.frame, R makes a copy of the whole data.frame using the '*tmp*' mechanism (this does not happen for components of a list, tracemem( ) on R-2.6.2 says so). Suggested solution :: Store the columns of the data.frame as a list inside of an environment slot of an S4 class, and define the '[',
2007 Dec 23
1
Problem with initialize of S4 classes
Dear all Below is the code for "scriptPreFilter.R" which gives the following result: > source("scriptPreFilter.R") > prefltr <- new("PreFilter", mad=c(0.5,0.01)) [1] "------initialize:PreFilter------" [1] "------initialize:Filter------" > str(prefltr) Formal class 'PreFilter' [package ".GlobalEnv"] with 2 slots
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
2012 Aug 05
1
setting invalid fields on reference classes sometimes allowed
I've found that reference class objects tend to behave like plain old environments wrt field access, unless a method on e.g. $<- is explicitly defined. Here is a code snippet: library(methods) Foo <- setRefClass("Foo") foo <- Foo$new() foo$a <- 2 # why does this succeed? not a valid field! ## set a silly $<- method setReplaceMethod("$", "Foo",
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"),
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,...)
2003 Jul 26
2
How to make "<-" generic?
Hi, perhaps a little bit unusual: is it possible to use "<- " as generic function with a new signature? The following example doesn't work: > isGeneric("<-") [1] FALSE > setClass("A",representation(x = "numeric")) [1] "A" > setClass("B",representation(x = "numeric")) [1] "B" > myAssign.A <-
2006 Oct 31
1
setReplaceMethod
Hi If x <- 1:10 then x[5] <- 1i will promote x to be a complex vector. Suppose I have an S4 class "brob", and have functions is.brob(), as.brob(), as.numeric() and so forth (minimal self-contained code below). If x is numeric (1:10, say) and y is a brob, what is the best way to make x[5] <- y promote x to a brob in the same way as the complex example? Or is
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
2005 Aug 05
1
S4 generating function
Can someone explain what the problem is when I use the generating function? And how to get debug() to stop in the Superclass initialize method? ---- source ----- setClass("Superclass", representation(id = "character"), contains = "VIRTUAL") setMethod("initialize", signature(.Object = "Superclass"),
2007 May 25
1
Question about setReplaceMethod
Hi I have the code like I show below. The problem here is that I have a setReplacementMethod to set the value of my class slot. However, this function doesn't work when I call it within another function definition (declared by setMethod) of the same class. I do not understand this behavior that much. I'm wondering how to make this work? Any help would be really appreciated. Thank you.
2017 Jun 23
1
setReplaceMethod creates 'object' in the userworkspace
Hi, I recognized that the function 'setReplaceMethod' is creating a character vector in the user workspace having the name (e.g. "newClass") of the class used as value. If you can sort out a mistake by myself, I would like you to file a bug report. BBFN, Jonathan setClass("newClass", representation(value="numeric")) setMethod(f = "initialize",
2017 Jun 23
1
setReplaceMethod creates 'object' in the userworkspace
Hi, I recognized that the function 'setReplaceMethod' is creating a character vector in the user workspace having the name (e.g. "newClass") of the class used as value. If you can sort out a mistake by myself, I would like you to file a bug report. BBFN, Jonathan setClass("newClass", representation(value="numeric")) setMethod(f = "initialize",