Displaying 20 results from an estimated 900 matches similar to: "Overloading S4 methods"
2012 Aug 03
1
Interaction between callNextMethod() and selectMethod()
Hi,
Strange things happen. Here is a simple example:
> setClass("A", contains="integer")
> setMethod("as.matrix", "A", function(x, ...) t(callNextMethod()))
Creating a generic function for ?as.matrix? from package ?base? in
the global environment
[1] "as.matrix"
> a <- new("A", 1:3)
> as.matrix(a)
2006 Oct 04
1
Default argument value for "["
Dear all,
After installing R 2.4.0, a definition of "[" for an S4 class has
stopped working as the default for drop in the generic, TRUE, appears to
override the default in the method
The method is defined for demonstration purposes as
setMethod("[", signature(x="FLQuant"),
function(x, i="missing", j="missing", k="missing",
2008 May 20
1
S4 generic for lowess
Hi,
A lowess method is defined in our package for one of our S4 classes. To
explicitely define the generic this is being used
if (!isGeneric("lowess"))
setGeneric("lowess", useAsDefault = lowess)
This works fine for many other methods inherited from various R
packages. In this case a warning is issued in R CMD check:
* checking R code for possible problems ... NOTE
2007 Jun 04
2
locked environment and inheritance
Hi,
I have a S3 package with namespace called "myS3Pkg". Inside my package I would like to create
a S4 class which extends (adds 2 slots) another S4 class from some other package. The class
should be created in "myPkg" environment (and not global environment).
Using:
setClass("myS4class", representation("otherS4class", mydata = "numeric"),
2007 Apr 19
2
setClass inside a function
Hello,
I would like to create a function that gets passed a class name and then calls setClass, and a few other functions, inside. I have done this in the past with setmethod, creating accessors for all slots in a set of S4 classes. But setClass is choking when my function is called isnide a package, telling about an error in exists(cname, where). I assume this to be a problem with the
2006 Oct 11
1
dispatching on group generics with more than one formal
please see the code below. foo2 fails to dispatch correctly, but foo
does fine. i have tried 'cacheMetaData(1)' and a number of different
variants of 'cacheGenericsMetaData', on the possibility there is a
caching issue. but i still can't sort it out.
also one general question: does it really matter what's in the body
of the function definition in a
2019 Mar 14
2
selectMethod() can fail to find methods in situations of multiple dispatch
Here is an example:
setGeneric("foo", function(x, y) standardGeneric("foo"))
setMethod("foo", c("numeric", "ANY"),
function(x, y) cat("I'm the foo#numeric#ANY method\n")
)
Dispatch works as expected but selectMethod() fails to find the method:
> foo(1, TRUE)
I'm the foo#numeric#ANY method
>
2004 Jun 16
2
Loading 'akward' data file
Generally you'd use file() to open the file, then use readLines(), say
inside a while() loop to read one `chunk' at a time. However, your example
looks a bit strange. The possibility of empty line makes it a bit more
complicated, by that last couple of lines seems to suggest that you could
have a line of data follow by another line of data without variable label.
If that's true, I
2019 Mar 22
2
selectMethod() can fail to find methods in situations of multiple dispatch
Hi Michael,
Thanks for looking into this. I suspect that truncation of ANY suffixes from method signatures is also the culprit behind the sudden breakage of aliases of the form \alias{foo,numeric-method} when a method without the ANY suffix in its signature gets added to the ecosystem. See my post about this to the Bioc-devel mailing list a couple of months ago:
2005 Jun 14
1
operators as S4 methods
Dear all,
I need to re-define some mathematical operators (+, *, /, etc) for an S4
class based on array. All references I have found (S Programming, Green
Book) show how to define S3 methods for this (like in page 89 of S
Programming for "-.polynomial"). What is the preferred S4 way for doing
this? I hope I haven't missed some obvious piece of documentation.
Many thanks,
Iago
2019 Mar 22
2
selectMethod() can fail to find methods in situations of multiple dispatch
Fine with me as long as eliminating the inconveniences associated with it can be put on the roadmap. The alias instability and the fact that the user has no way to know if s/he should do ?`foo,numeric-method` or ?`foo,numeric,ANY-method` to find the method has been a long-standing problem.
H.
On 3/21/19 21:29, Michael Lawrence wrote:
If we started over, I'd try to avoid this sort of
2007 May 01
1
Possible problem with S4 dispatch
Hi,
First a bit of disclaimer... I haven't isolated this problem into an
easy to reproduce case, and I won't be surprised if the root cause is
a fault in my code's use of name spaces or some such.
The error I'm seeing is one in which the desired method is not found.
What worries me in terms of my expectations of how to debug the
problem is that showMethods and selectMethod both
2003 Aug 21
2
mcmc
Hello,
I am about to move all of my modelling work into R, and I have been
investigating the present state of MCMC and Bayesian methods in R.
Following a thread on the mailing list in 2000, I have looked at
mcmcpack and Hydra. Three years down the line, is there anything new in
this area? I have used both MCSim and WinBUGS in the past. The first one
seems promising, but is too focused towards
2004 Jun 21
2
Cross build Makefile
Hello,
I am trying to use Yan and Rossini's Makefile for cross building Windows
versions of R packages in Linux with R 1.9.0. When compiling R with the
mingw tools I get an error about expm1 being undeclared when first found
at src/main/arithmetic.c:1019
If I fiddle a bit with it later on I also get errors about log1p bein
undeclared.
Any idea what should I look for?
I am using R 1.9.0 in
2004 Jun 21
2
Cross build Makefile
Hello,
I am trying to use Yan and Rossini's Makefile for cross building Windows
versions of R packages in Linux with R 1.9.0. When compiling R with the
mingw tools I get an error about expm1 being undeclared when first found
at src/main/arithmetic.c:1019
If I fiddle a bit with it later on I also get errors about log1p bein
undeclared.
Any idea what should I look for?
I am using R 1.9.0 in
2008 May 28
1
Cross-compilers for 2.7.0
Hello,
Am I right in thinking the cross-compilations tools, kindly maintained
by Prof Ripley, are still waiting to be updated for 2.7.0?
Thanks,
Iago
--
Iago Mosqueira
Cefas
Systems Modelling
Pakefield Rd.
Lowestoft NR33 0HT
U.K.
+44 (0)1502 558003
2006 Mar 29
1
Bundle internal dependencies
Dear all,
When creating a bundle with some internal dependencies (package B in
bundle depends on package A), would having the same version installed
suffice? Can I ignore the dependencie in package B's description? The
test of package B fails when calling data() for an object in pacakge A,
so I am not sure right now whether the whole dependencie is not being
met or simple relates to data().
2009 Feb 04
1
lattice key inside panel
Hello,
I am trying to draw a key inside a single panel in a lattice xyplot. The
panel function uses panel.number() to use a slightly different style for
one of the panels. Once inside than panel I am using
draw.key(list(text=list(lab='catch'),
lines=list(lwd=c(2)),
text=list(lab='landings'),
rectangles=list(col=rgb(0.1, 0.1, 0, 0.1)),
x=0,
2002 Nov 05
1
function showMethods and inheritance
Hi,
The following question might come from my (deep) misunderstanding
of the concepts in the package 'methods'.
I have a class 'A', and a class 'B' inheriting 'A' (so defined
with 'setClass' and the parameter 'contains="A"'. The class
A has a method 'mymethod'. A call to 'showMethods("mymethod")'
return the
2012 Oct 01
1
False positive note about ambiguous dispatch
Hi,
In the situation below the note issued by the dispatch algo doesn't
seem right:
setClass("A", representation(stuff="complex"))
setAs("ANY", "A", function(from) new("A", stuff=as.complex(from)))
> as(6, "A")
An object of class "A"
Slot "stuff":
[1] 6+0i
> as(6L, "A")