Displaying 20 results from an estimated 7000 matches similar to: "[R] S4 method dispatch matrixOrArray (fwd)"
2006 Apr 12
1
S4 method dispatch matrixOrArray
I have some code where the primary dispatching is on
other parameters so I'd like not to have to create a
set of functions for "matrix" and another duplicate
set for "array". But the class union technique isn't
working as implemented below and I don't have my Green
book with me. How do I fix my infinite recursion problem?
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
2015 Jan 28
2
[Q] Get formal arguments of my implemented S4 method
I'm attempting to reflect the information for use with corresponding
fields in GUI (in a different package), to provide default values,
argname as key for UI label lookups, etc.
So I want something much more like the formals of the implementation:
{
"object",
"method": c("median", "vs", "tukey"),
2004 Jul 06
1
questions about setMethod("Arith", ...)
Hi,
we have some questions concerning the definition of new arithmetic methods.
In our package "distr" (on CRAN) we define some new arithmetic methods
for "+", "-", "*", "/".
After loading "distr" the corresponding arithmetic methods work. Now, if
we define a new
class and also a new method for one of the arithmetic methods
2015 Jan 29
3
[Q] Get formal arguments of my implemented S4 method
On Jan 28, 2015, at 6:37 PM, Michael Lawrence <lawrence.michael at gene.com> wrote:
> At this point I would just due:
>
> formals(body(method)[[2L]])
>
> At some point we need to figure out what to do with this .local() confusion.
Agreed, definitely. The current hack is to avoid re-matching arguments on method dispatch, so a fix would need to be fairly deep in the
2015 Jan 28
2
[Q] Get formal arguments of my implemented S4 method
Interrogating some (of my own) code in another package.
>norm.meth <- getMethod("normalize", "MatrixLike")
>message("str(norm.meth)")
>str(norm.meth)
>message("show(norm.meth at .Data)")
>show(norm.meth at .Data)
Last show() displays this:
function (object, ...)
{
.local <- function (object, method = c("median",
2005 Jul 19
1
S4 Dispatching
Is it possible for S4 to (continue) dispatch to a class
created during dispatching? The code below doesn't work;
is this not possible or have I ommitted something?
Concept was to create a SEXP with R_AllocatePtr, give it
a class attribute, and continue dispatch. Example code
below omits multiple parameters that can be different types.
Essentially, any parameter would be converted to an
2005 Dec 29
1
trouble with S4 methods for group "Summary"
Hello. This question concerns the Methods package. I have created a
new class and am trying to set a method for it for S4 group generic
"Summary". I have run into some signature problems. An example:
> setClass("track", representation(x="numeric", y="character"))
[1] "track"
> setGeneric("max", group="Summary")
2012 Apr 12
1
R-2.15.0 and Exporting Methods Converted To S4 Generic
Late to the show on this release, unfortunately.
One of our production packages no longer builds under R-2.15.0
with the following message.
** testing if installed package can be loaded
Error: Function found when exporting methods from the namespace
'SuperCurve' which is not S4 generic: 'image'
Possibly relevant clues follow:
## From R/AllGenerics.R
if
2006 Oct 17
1
Caching bug with showMethods?
showMethods isn't reporting inherited methods when it is first
called. The methods are there and after calling them, showMethods
gives the right output.
Here is an example (using R-devel r39647):
setClass("A", representation(x="numeric"),
prototype=list(x=1))
setClass("B", contains="A",
prototype=list(x=2))
2011 Feb 05
1
Seeking help to define method for '+'
Dear all, I am trying to define "+" method for my newly defined s4 class
which is as follows:
setClass("Me", sealed=F,representation(x1 = "numeric", x2 = "character"))
new1 <- new("Me", x1=2, x2="comment1")
new2 <- new("Me", x1=3, x2="comment1")
setMethod("+", "Me",
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)
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 Jun 02
1
showMethods doubt
Hi,
I'm developing in S4 and I wanted to see the methods for a specific
class using showMethods but I didn't succed. Can someone help ? See the
example below.
setClass("myclass",
representation(
name ="character"
)
)
setGeneric("mymeth", function(obj, ...){
standardGeneric("mymeth")
}
)
setMethod("mymeth",
2015 Jan 29
0
[Q] Get formal arguments of my implemented S4 method
At this point I would just due:
formals(body(method)[[2L]])
At some point we need to figure out what to do with this .local() confusion.
On Wed, Jan 28, 2015 at 10:07 AM, Roebuck,Paul L <PLRoebuck at mdanderson.org>
wrote:
> I'm attempting to reflect the information for use with corresponding
> fields in GUI (in a different package), to provide default values,
> argname
2010 Jul 07
2
how to define method for "+" function in a new class
Dear R developers,
I have a new class, which I called "Molecule", and have tried to define =
a "+" operation for 2 objects of this class.
This is what I have written so far, although the method is not complete =
(I'm trying to look at it at intermediate stages):
setMethod(
f=3D"+",
signature(x=3D"Molecule",y=3D"Molecule"),
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",
2010 Aug 26
1
Passing arguments between S4 methods fails within a function:bug? example with raster package.
Dear all,
This problem came up initially while debugging a function, but it
seems to be a more general problem of R. I hope I'm wrong, but I can't
find another explanation. Let me illustrate with the raster package.
For an object "RasterLayer" (which inherits from Raster), there is a
method xyValues defined with the signature
2010 May 21
1
S4 method defined but not used
Dear R developers,
I am having a slightly weird issue with a S4 method defined in my package adegenet 1.2-4, with R 2.11.0. As far as I know, the problem is new, and the code implementing the method has not changed for more than a year and worked well so far.
The problem is the following. I define, in the package, a method "[" for the S4 class 'genind'. The method's
2005 Jun 20
3
How to define S4 methods for '['
Folks:
This is a question about the S4 formal class system.
Suppose I have a class, 'foo', defined by:
setClass('foo',representation(dat='matrix', id='character') )
I wish to define a '[' method for foo that will extract from the 'dat' slot.
I would have thought that the following would work, but it doesn't: