Displaying 20 results from an estimated 8000 matches similar to: "S4 problems"
2009 Dec 03
1
S4 and head() problems
Hi
I am having difficulty defining an S4 method for head() and tail().
I can't quite provide minimal self-contained code
because the problem appears to require the whole corpus
of my package; and there also appears to be a difference
between sourcing the lines directly, and having them
installed in a package.
The lines in question (I think) are:
setClass("mdm",
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 Oct 26
1
S4 methods for rbind()
Hello.
I am trying to write an S4 method for rbind(). I have a class of objects
called 'mdm', and I want to be able to rbind() them to one another.
I do not want the method for rbind() to coerce anything to an mdm object.
I want rbind(x1,x2,x1,x2) to work as expected [ie rbind() should take any
number of arguments].
This is what I have so far:
setGeneric(".rbind_pair",
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
2007 Aug 07
1
S4 methods: unable to find an inherited method
Hello all,
I consider myself pretty new to the whole OO based programming so
I'm sorry if I'm doing something stupid.
> xml<-read.metlin(url)
Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "read.metlin",
for signature "url"
>read.metlin
standardGeneric for "read.metlin" defined from package
2010 Nov 10
1
S4 package warning
Hello everyone. R-2.12.0, suse linux 11.3.
I am debugging a package that uses S4 methods
and R CMD check gives the following warning:
> Warning in methods::findMethods(g, env) :
> non-generic function 'mdm' given to findMethods()
> See the information on DESCRIPTION files in the chapter 'Creating R
> packages' of the 'Writing R Extensions' manual.
I
2013 May 08
1
Namespace/inheritance problem in S4 methods for a union class
Hi,
I started this post on bioc-devel but this seems to be more general:
https://stat.ethz.ch/pipermail/bioc-devel/2013-May/004311.html
See reproducible example from Martin below.
Thank you.
Renaud
---------- Forwarded message ----------
From: Martin Morgan <mtmorgan at fhcrc.org>
Date: 7 May 2013 19:55
Subject: Re: [Bioc-devel] ExpressionSet and LumiBatch: inheritance problem
in S4
2007 Apr 15
1
unable to find inherited method for function "edges", for signature "ugsh", "missing"
I am new to using S4 methods and have run into this problem (on Windows XP using R 2.4.1): I am writing a package in which I use the graph package. I define my own classes of graphs as:
setOldClass("graphsh")
setOldClass("ugsh")
setIs("ugsh", "graphsh")
(I know that I "should have" used setClass instead - and I will eventually - but right now
2006 Sep 15
1
setMethod() woes
Hello everybody
R version 2.4.0 alpha (2006-09-15 r39323), MacOSX 10.4.7
Next S4 problem.
I have "brob" objects that are large real numbers, and now I want "glub"
numbers that are to be a pair of glubs that represent complex numbers.
I want to define binary operator "+" so that if either the left or right
argument are glubs, it uses .ArithGlub.
If either
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",
2010 Sep 03
3
S4 Method Signatures
Hello,
If the signature of a method defines which generic it implements then I'm confused about why this minimal example I invented won't work :
setGeneric("myFun", function(rs, ...){standardGeneric("myFun")})
setGeneric("myFun", function(cs, ...){standardGeneric("myFun")})
setMethod("myFun", "numeric", function(rs, colour =
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 Feb 14
3
S4 classes and methods with optional arguments
Hi,
i have used S4 classes to implement a unified access to random number generators
(package rstream on CRAN).
I have used a construct to allow optional arguments:
if(!isGeneric("rstream.sample"))
setGeneric("rstream.sample", function(stream,...) standardGeneric("rstream.sample"))
setMethod("rstream.sample",
2017 Sep 22
2
S4 method implementation for S3 class
Hi all,
I'm trying to implement the matrix multiplication operator, which is
S4 generic, for an old-style S3 class. The following works as
expected:
x <- 1:10
class(x) <- "myClass"
setOldClass("myClass")
setGeneric("myMethod", function(x, y) standardGeneric("myMethod"))
setMethod("myMethod", c("myClass", "myClass"),
2008 May 10
2
Hashes as S4 Classes, or: How to separate environments
For learning purposes mainly I attempted to implement hashes/maps/dictionaries
(Python lingua) as S4 classes, see the coding below. I came across some rough S4
edges, but in the end it worked (for one dictionary).
When testing ones sees that the dictionaries D1 and D2 share their environments
D1 at hash and D2 at hash, though I thought a new and empty environment would be
generated each time
2006 Jan 25
2
Using substitute from inside an S4 method
Hi all,
I would like to access the name of a variable passed to an S4 method.
For a function, I would do this:
f <- function(x) as.character(substitute(x))
This also works for a the examples I have tried for methods that do
not have extra, non-dispatch args:
setGeneric("A", function(x, ...) standardGeneric("A"))
setMethod("A",
2010 Mar 15
2
Strange behavior of assign in a S4 method.
Hi the list,
I define a method that want to change an object without assignation
(foo(x) and not x<-foo(x)) using deparse and assign.
But when the argument of the method does not match *exactly* with the
definition of the generic function, assign does not work...
Anything wrong?
Christophe
#------ Does not work ------#
2005 Mar 25
1
S4 methods semantics questions
Some quick questions about S4 methods.
Does the typing of S4 methods mean that lazy evaluation is no longer
possible? It seems that you would need to evaluate the arguments to
determine their type at dispatch.
Second, what role, if any, do default arguments play in S4 methods? I
notice that you can put default arguments into generics but that the
dispatch is still done on the type of the
2012 Sep 18
0
S4, polymorphism, and parallelization
I am running Rmpi and MPICH2 to do parallelization in a Windows 7 machine.
I am only using my PC's cores. Parallelization for standard R code works
fine. For S4 code I am having the following problem:
Let us say I have a class A and a subclasses B and C (both B and C
"contains" A). I declared a method
setGeneric(
name = "superClassMethod",
def = function(object)
2008 Jan 22
1
deparse, substitute and S4 generics
Hello everyone,
I encountered the following confusing behavior of 'deparse' and
'substitute' while programming with S4 classes (see example below). It
seems like the presence of '...' argument in the definition of the
generic generates the problem. I have no clue why, can anyone explain
that to me? Are there any "workarounds"?
Thanks a lot for your time!