Displaying 20 results from an estimated 30000 matches similar to: "S4 Methods dispatch"
2006 Aug 31
1
S4 Method Dispatch for Sealed Classes
Hi,
I encounter a problem with method dispatch with S4 classes, using the
'sealed' parameter in setClass.
See that example below:
setClass("X",representation(x="numeric"),sealed=TRUE)
setGeneric("foo",function(x) standardGeneric("foo"))
setMethod("foo",signature("X"),function(x) print("foo(X)"))
x <-
2006 Apr 13
2
[R] S4 method dispatch matrixOrArray (fwd)
What a delicious example! (I'm taking the liberty of sharing it with
r-devel, since it raises some good issues.)
You have two questions, presumably:
1 - how could the order of the setMethod calls make a difference in the
results?
2 - what's causing the infinite loop & how could it be avoided, reliably?
Second question first. The danger sign is the "vector" method:
2009 Aug 05
1
S4 method dispatch: coercion of arguments with setAs defined
Hi list,
I've got a class B that contains a slot obj of class A. I'd like to be
able to call all the methods of class A directly on objects of class B
as if I had called the method on slot obj. This without overloading all
methods of class A to work on class B.
I don't define B as an extension of A, because I want class B to also
work with objects of classes that inherit from
2006 Sep 11
1
S4 Method dispatch in recent 2.4.0alpha
I use 2 packages that both implement a S4 plot method, where one package
depends on the other (the bioconductor package globaltest which depends
on multtest). When the plot method is used from within the package, it
seems the default plot method is used, and an error is generated. When
the method is invoked from the console, the plot is created correctly. I
have reproduced this with 2 small
2009 Dec 15
1
S4 dispatch and S3 "connection" objects
Hello,
I'm trying to get S4 dispatch on S3 "connection" objects.
So I do :
setOldClass( "connection" )
and then :
setGeneric( "bling", function(object) standardGeneric( "bling" ) )
setMethod( "bling", "connection", function(object) cat( "gotcha ",
as.integer(object), "\n" ) )
but I get :
f <- file(
2010 May 29
3
S4 dispatch for .DollarNames (utils)
Hello,
I'm trying to make .DollarNames generic and implement a method for it in
a package. .DollarNames is the function that is now called to get
completion possibilities.
My R code looks like this:
setGeneric( ".DollarNames" )
setClass("track",
representation(x="numeric", y="numeric"))
## A class extending the previous, adding one more
2011 May 27
1
Reference Classes/S4 Classes: can method dispatch check superclasses BEFORE resorting to method for "ANY"?
Dear list,
is it possible that method dispatch checks for superclasses/virtual
classes before checking "ANY"?
I'd like to build a generic initialization method for all my Reference
Class (say "MyDataFrame") objects by having them inherit from class, say
"MyRefClassVirtual" (which would have to be a virtual S4 class; there
are no virtual Reference Classes,
2024 Sep 27
1
Disabling S4 primitive dispatch during method resolution affects namespace load actions
Hello,
This problem originally surfaced as an interaction between 'brms',
'rstan' and 'Rcpp' [1]: a call to dimnames() from the 'brms' package on
an object of an S4 class owned by the 'rstan' package tried to load its
namespace. rstan:::.onLoad needs to load Rcpp modules, which uses load
actions and reference classes. Since methods:::.findInheritedMethods
2014 Oct 07
1
S4 Method Dispatch for Class Defined as Attribute
Hello,
I am writing an interface to some functions from the CRAN package pamr, which is poorly written.
I have a S4 method I declared with setMethod. I'd like to provide a signature of "pamrtrained" which is the class of object that training creates. The last two lines of code of pamr.train are :
class(junk) = "pamrtrained"
junk
How can I dispatch on these kinds
2024 Sep 27
1
Disabling S4 primitive dispatch during method resolution affects namespace load actions
>>>>> Ivan Krylov via R-devel
>>>>> on Fri, 27 Sep 2024 13:32:27 +0300 writes:
> Hello,
> This problem originally surfaced as an interaction between 'brms',
> 'rstan' and 'Rcpp' [1]: a call to dimnames() from the 'brms' package on
> an object of an S4 class owned by the 'rstan' package tried to
2004 Nov 18
1
Method dispatch S3/S4 through optimize()
I have been running into difficulties with dispatching on an S4 class
defined in the SparseM package, when the method calls are inside a
function passed as the f= argument to optimize() in functions in the spdep
package. The S4 methods are typically defined as:
setMethod("det","matrix.csr", function(x, ...) det(chol(x))^2)
that is within setMethod() rather than by name before
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
2007 Mar 15
4
R 2.5.0 devel try issue in conjuntion with S4 method dispatch
Hi,
after updating R 2.5.0 devel yesterday we today observed many new
unexpected failures in our daily package build and test system runs,
which can be traced to recent changes in the implementation in try()
(as noted in NEWS).
Investigating this new implementation I come across an issue in
conjuntion with using S4 classes and methods. try(expr) does not return an
object with attribute
2010 Sep 07
1
Dispatch method on S3 or S4 class
Hello,
I've been attempting to make a generic method that dispatches on the first argument, which can be either an S3 or an S4 class. This is as far as I've gotten. Any suggestions about what to try next ?
library(aroma.affymetrix)
library(GenomicRanges)
setGeneric("analyse", function(x, y, ...) standardGeneric("analyse"))
setMethodS3("analyse",
2009 Jul 20
1
S4 method dispatch with inheritance
Hi,
I'm trying to create a new S4 class (myMatrix) which for now just
extends dgCMatrix (from package Matrix). Then I want to use "[" which is
defined in Matrix.
Out of the box with "[" (defined in Matrix) I lose the class information
and the result is an object of class dgCMatrix. If I specify a
"["-method for myMatrix, it is not used because a signature
2015 May 10
2
S4 method dispatch sometimes leads to incorrect when object loaded from file?
Loading an S4 object from a file without first loading the library sometimes (?,
the example below and actual example involves a virtual base class and the show
generic) leads to incorrect dispatch (to the base class method).
The attached package reproduces the problem. It has
setClass("A")
setClass("B", contains="A")
setMethod("show", "A",
2004 Apr 19
3
How to write an S4 method for sum or a Summary generic
If I have a class Foo, then i can write an S3 method for sum for it:
>setClass("Foo",representation(a="integer"));aFoo=new("Foo",a=c(1:3,NA))
>sum.Foo <- function(x,na.rm){print(x);print(na.rm);sum(x at a,na.rm=na.rm)}
>sum(aFoo)
But how do I write an S4 method for this? All my attempts to do so have
foundered. For example
2005 Apr 11
0
S4 group methods don't dispatch for "Summary"?
Hi all,
I am having a little problem with S4 group generics (apologies if I
get some terminology wrong below). I'm finding I can set methods for some
group generic functions, but not others:
> setClass("foo", representation(data="numeric"))
> x <- new("foo", data=1:10)
## Setting "Ops" works just as expected:
> setMethod("Ops",
2009 May 18
1
S4 method dispatch and namespaces: why is default method selected
Hi,
I ran into the following peculiarity involving S4 method dispatch and
namespaces.
I develop a package which have a namespace and which depends on 'pixmap'
package, which itself does not have a namespace.
Now, in my package I have a class which has a slot for objects from
class "pixmap" and I
want to have a "plot" method for this new class. Not to clutter the
2013 Mar 13
1
S4 generic not exported correctly / incorrect dispatch?
In this post
https://stat.ethz.ch/pipermail/bioc-devel/2013-March/004152.html
a package author reports that S4 dispatch fails. I can reproduce this with a
PkgA (attached; 'intervals' is a relatively light-weight CRAN package) that has
DESCRIPTION with
Depends: intervals
Imports: graphics
NAMESPACE:
importFrom(graphics, "plot")
export("plot")