Displaying 20 results from an estimated 9000 matches similar to: "S4 methods semantics questions"
2005 Dec 23
2
cairo anyone?
Has anyone taken a shot at a Cairo graphics device yet? I half
expected to see one on either Paul's pages or Omegahat. :-)
---
Byron Ellis (ellis at stat.harvard.edu)
"Oook" -- The Librarian
2007 Nov 01
3
Curry: proposed new functional programming, er, function.
Hi all (especially R-core) I suppose,
With the introduction of the new functional programming functions into
base I thought I'd ask for a Curry() function. I use a simple one that
looks this:
Curry = function(FUN,...) { .orig = list(...);function(...)
do.call(FUN,c(.orig,list(...))) }
This comes in really handy when using say, heatmap():
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",
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")
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'
)
2010 Jul 21
1
Bug: broken exception handling in S4 methods
Hi all:
we have noticed for quite a while that certain errors cannot be handled
by R try, tryCatch etc blocks, but it was fairly difficult to understand
what were the conditions for this incorrect behaviour. Finally I stabbed
across a very understandable case, which is outlined in the (runnable)
example below.
The main message is: wrapping an S4 method call in a try block will not
help if an
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",
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
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 ------#
2003 Sep 14
2
Problem building methods package?
For the last, I dunno, week or so I've been unable to build R... I
finally took the time to investigate and the crash is in building
'methods':
all.R is unchanged
../../../library/methods/man/methods.Rd is unchanged
make[2]: `Makedeps' is up to date.
../../../../library/methods/libs/methods.so is unchanged
make[1]: Nothing to be done for `Rfiles'.
Any clues to where this
2006 Oct 19
1
default arguments in generics and methods
i believe the following is true but would appreciate confirmation
that it is intended behavior and will continue:
if a default argument is employed in the definition of a generic
function, and the generic is called with the argument in question
(call it 'ARG') missing, then the method for signature (..., ARG =
"missing", ...) will be called by 'standardGeneric'
2007 Aug 16
1
methods and try()
Hi all, I'm having a problem with some sort of interaction with try()
and methods, I think.
The setup is as follows, I have an S4 class that holds an environment
and I would like to evaluate the right hand side of a function inside
that environment. No problem there.
However, if the formula involves a symbol that doesn't exist, which
may or may not happen, it fails as it should and
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!
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",
2004 Jun 26
1
S4 group "Math", "getGroupMembers", "genericForPrimitive"
Hi,
I found the following on Windows 2000/NT
R Version 1.9.1 (2004-06-21) (also Version 1.9.0):
The S4 group "Math" doesn't work as documented; i.e., "log", "log10",
"gamma" and "lgamma" are included
in the documentation but don't work. See example code below.
Moreover, what about 'genericForPrimitive' which is used
in
2011 Nov 09
1
Define S4 methods for 'plot'
Hi the list
I am creating a package and I have a problem to define a S4 method for plot.
I define a class 'A' and a class 'B'. I want to define a function plot for
signature c(A,missing) and another method plot for signature c(A,B). My code
is the following :
In /package/R/ directory:
--- main.R ---
setGeneric("plot",function(x,y,...){standardGeneric("plot")})
2009 Jun 05
2
Problem with generic methods
Hi
I want to create a new generic method, but I end up with an error
(evaluation nested too deeply). see the transcript below.
The function beginYear.Fun() works, but not beginYear.
I have no idea why.
Any ideas welcome,
Rainer
> setClass("fun", representation(x = "numeric"))
[1] "fun"
> new("fun")
An object of class ?fun?
Slot "x":
2002 Jun 19
1
Anon CVS updates?
Is the anonymous CVS repository for R presently broken? There haven't been
many updates coming through and the repository files seem to differ
significantly from the rsync version of R-devel...
Byron Ellis (bellis@hsph.harvard.edu)
"Oook" - The Librarian
Please finger bellis@hsph.harvard.edu for PGP keys
2010 May 12
1
slot assignment in S4 classes
Hi R friends,
I'm still studying S4 classes and I have a question about slot assignment. Why would I have to use a special setter method [example 2 below] if I can assign data to a slot directly when I call new() [example 1 below]?
## first way to do it (the idiosyncratic way?)
setClass(Class = "TestClass", representation = representation(myDf = "data.frame"))