Displaying 20 results from an estimated 344 matches for "setgeneric".
2008 Mar 13
3
Sealed for setGeneric
Hi the list
When two setGeneric occurs on the same function, the second erage the
first and erase all the function previously define.
Is it possible to prevent that ? Is it possible to declare a setGeneric
that can not be erased later ?
Something like the |sealed for setMethod...|
||
|Thanks|
||
Christophe
2010 Jan 19
1
calling setGeneric() twice
Is it safe to call setGeneric twice, assuming some setMethod's for the
target function occur in between? By "safe" I mean that all the
setMethod's remain in effect, and the 2nd call is, effectively, a no-op.
?setGeneric says nothing explicit about this behavior that I can see.
It does say that if there is an...
2013 Feb 02
1
setGeneric() gives "must supply skeleton" when checking package
r-devel,
In a development version of the CRAN package metrumrg, I write ...
require(reshape)
setGeneric('cast')
setOldClass(c('keyed','data.frame'))
setMethod('cast','keyed', function ...)
The result is satisfactory when sourcing the code directly, but when
checking the package (which has 'reshape' as a dependency in the
DESCRIPTION file) I get the fol...
2013 Feb 14
4
2 setGeneric's, same name, different method signatures
...t;) returns a value. class B's bB() compares
values in two B objects, and returns the minimum, so bB(B1, B2) are its
methods.
after loading the file, i see the method for A's bB has disappeared (as
measured by showMethods("bB"), as well as trying bB(A). if i have R
re-parse the setGeneric/setMethod A's bB(), then B's bB() disappears.
somehow my code, or my model of how things work, is wrong. any ideas
what am i missing?
cheers, Greg Minshall
----
setClass("A",
representation(
x="numeric"));
setMethod(
f="initialize",...
2002 Jan 06
1
How to get setGeneric() to work?
Dear all, I can't see how setGeneric() works. I know perfectly well how to
define
library(methods);
setClass("Square", representation(side="numeric"));
# Will become the default method.
getArea <- function(object) {
stop(paste("Method getArea() is not defined for this class:",
data.clas...
2003 May 27
1
setGeneric?
In the last few days I've received couple of messages pointing out that our SparseM
package fails to install on the patched version of 1.7.0. Laurent Gaultier kindly
suggested that replacing:
setGeneric("as.matrix.csr")
by
setGeneric("as.matrix.csr", function(x, nrow, ncol, eps) standardGeneric("as.matrix.csr"))
was sufficient to fix the problem. Unfortunately, the story is a bit more complicated
than that. After this substitution and some similar ones for a few...
2014 Nov 25
0
problem with setGroupGeneric from package methods
...up generic. I looked in the sources of package "methods" for the
## way group generics are defined and switched to using argument "known members"
## (see below) instead of the following commands.
## setGroupGeneric("pcfData", function(x) NULL)
## setGeneric("pc.nseasons" , group="pcfData") # ima setGeneric i pri pcSeason. Check!
## setGeneric("pc.nepochs" , group="pcfData")
## setGeneric("pc.nvariables" , group="pcfData")
## setGeneric("pc.namesofseasons" , gro...
2005 Dec 29
1
trouble with S4 methods for group "Summary"
...kage. 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")
[1] "max"
> setMethod("Summary", signature(x="track"), function(x, ..., na.rm)
callGeneric(x at x, ..., na.rm))
[1] "Summary"
> dd<-new("track", x=c(1,2), y="abc")
> max(dd)
[...
2009 Dec 17
5
?setGeneric garbled (PR#14153)
Full_Name: Ross Boylan
Version: 2.10.0
OS: Windows XP
Submission from: (NULL) (198.144.201.14)
Some of the help for setGeneric seems to have been garbled. In the section
"Basic Use", 5th paragraph (where the example counts as a single line 3rd
paragraph) it says
<quote>
Note that calling 'setGeneric()' in this form is not strictly
necessary before calling 'setMethod()' for the sam...
2014 Jul 11
1
Namespaces and S4 Generics
I've installed R-devel
R Under development (unstable) (2014-07-09 r66111)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
and am trying to resolve some problems that I am seeing with my
SparseM package. In prior versions I explicitly had:
setGeneric("image", function(x, ...) standardGeneric("image"))
and then used setMethod to define a method for the class matrix.csr
but my reading of the setGeneric manpage suggests that this call to
setGeneric need not, and probably should not have this second
argument, and indeed, need...
2008 Nov 25
2
dots methods: dispatch issues
There seems to be a bug arising when using multiple S4 generics with "..."
as the signature.
The following code works as expected:
##############################################################
> setGeneric("rbind", function(..., deparse.level=1)
standardGeneric("rbind"),
+ signature = "...")
Creating a generic for "rbind" in package ".GlobalEnv"
(the supplied definition differs from and overrides the implicit generic
in package "b...
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'
)
)
setMethod(...
2004 Jun 19
0
setGeneric / standardGeneric when args are not "literals" - corrected
This is a correction to my previous message, I forgot to swap two lines
in the body of setMakeGenericMethod. Sorry about that. The correct (full
message) reads like this:
Hi,
This works
> setGeneric("clear", function(obj) standardGeneric("clear"))
[1] "clear"
but this doesn't. Why?
> funName <- "clear"
> setGeneric(funName, function(obj) standardGeneric(funName))
Error in .recursiveCallTest(body, fname) :
(converted from warning) The bo...
2010 Apr 19
0
S4-based package failure: setGeneric example#1
I am a newbie package builder who successfully built a "Hello world" package
but am now having trouble building a package with S4 functionality. I
thought I would start by building a package consisting of just the first
example under the setGeneric help page in a "fresh" 2.10.0 (windows) console
(methods loaded at startup). The example:
## create a new generic function, with a default method
props <- function(object) attributes(object)
setGeneric("props")
I executed those commands, then
package.skeleton("props&q...
2006 Dec 28
1
setGeneric and file order in a package
Are there any assumptions I can make about the order in which
different files in the R package subdirectory will be evaluated? For
example, will it be alphabetical in the file names? Will case
distinctions be ignored?
I ask because I would like to use setGeneric, as in
setGeneric("foo", function(x) standardGeneric("foo")) and am wondering
where that should go.
I realize I could explicitly test for the existence of the generic in
each spot, and execute setGeneric as needed. That seems wasteful and
error prone.
Is there other recommend...
2010 Jan 21
1
Rgeneric.py assists in rearranging generic function definitions
I've attached a script I wrote that pulls all the setGeneric definitions
out of a set of R files and puts them in a separate file, default
allGenerics.R. I thought it might help others who find themselves in a
similar situation.
The "situation" was that I had to change the order in which files in my
package were parsed; the scheme in which the ge...
2002 Sep 10
1
setGeneric(); R CMD check
...quot;dbApply"
It seems that the generic function dbApply lives in the .GlobalEnv when
the package is attached (w. library), but not in the package's environment.
I presume that's why check triggers the warning.
Is this the case?
*If* this is the case (i.e., packages with setGeneric()s need to be installed
as binaries), perhaps it should be documented somewhere.
... or am I missing something very basic?
> version
_
platform i686-pc-linux-gnu
arch i686
os linux-gnu
system...
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", c("rstream","numeric"),
function(stream,n=1) { ... [ code ] ... } )
Thus if rs is an instance of an rstream object one can a random
sa...
2011 Jan 20
1
setGeneric for residuals, etc
I'm experimenting with a few model-fitting classes of my own. I'm
leaning towards using S4 for my classes, but the R functions I'd want to
override (residuals, predict, etc.) are all S3 methods.
As I understand it, I could do setGeneric("residuals"), then add S4
specializations to it. However, I don't understand the full
consequences of doing this. Are there any drawbacks? Is there some
code that will not run properly if I do this? It feels like I'm
reaching in and modifying a core R function, which makes me...
2018 Apr 18
2
odd assignInNamespace / setGeneric interaction
...ase:::.qOrig(save = save, ...), "base")
This worked fine until he decide to load the distr package:
> suppressPackageStartupMessages(library(distr))
Error: package or namespace load failed for ?distr? in
loadNamespace(name):
there is no package called ?.GlobalEnv?
distr calls setGeneric("q"), which indirectly causes the environment
of base::q, .GlobalEnv, to be loaded as a namespace, causing the error.
Giving his replacement q function the environment getNamespace("base")
avoids the problem.
I can reproduce the problem by making a package that just calls
setGe...