Displaying 20 results from an estimated 11000 matches similar to: "Documentation of S3 and S4 classes, inheritance"
2005 May 23
1
SV: Documentation of S3 and S4 classes, inheritance
I am sure that I do not have the answer to your question - but I would like to add to your views regarding the S4-issue. I've been involved in the gRbase package for graphical modelling in R. The first version was implemented in S4 but now we have made a roll-back to using S3 methods.
While, I can see that S3 is not really comprehensive enough for 'proper' object oriented
2006 Mar 07
3
Making an S3 object act like a data.frame
"[.ggobiDataset" <- function(x, ..., drop=FALSE) {
x <- as.data.frame(x)
NextMethod("[", x)
}
"[[.ggobiDataset" <- function(x, ..., drop=FALSE) {
x <- as.data.frame(x)
NextMethod("[[", x)
}
"$.ggobiDataset" <- function(x, ..., drop=FALSE) {
x <- as.data.frame(x)
NextMethod("$", x)
}
> class(x)
[1]
2013 Mar 25
1
From Java to R OOP
Hi, I'm new to OOP in R so please forgive the naiveness of some of the questions. Here are a couple of them. It would be great if you can contrast to OOP in Java.
1. R's S4 appears to centered around a dispatch mechanism which in my understanding is just a way to implement polymorphism. Now, here's the snag, I thought polymorphism was an aspect of OOP not by itself the definition of
2010 Jul 22
1
class
Hello,
### I created two classes "A" and "B". "A" is the superclass of "B".
setClass("A", representation(s1="numeric"),prototype=prototype(s1=8))
setClass("B",contains="A",representation(s2="character"),prototype=list(s2="hi"))
myA=new("A")
myB=new("B")
#### I created
2009 Jun 05
1
S4: Initialization method called during setClass??
Dear UseRs,
A simple class inheritance example:
> setClass("test",representation(a="numeric"))
> setMethod("initialize","test",
function(.Object,x,...){
print("Initialization!!!")
callNextMethod(.Object,a=x,...)
})
> new("test",x=23)
[1] "Initialization!!!"
An
2019 Nov 01
3
R C api for 'inherits' S3 and S4 objects
Dear R developers,
Motivated by discussion about checking inheritance of S3 and S4
objects (in head matrix/array topic) I would light to shed some light
on a minor gap about that matter in R C API.
Currently we are able to check inheritance for S3 class objects from C
in a robust way (no allocation, thread safe). This is unfortunately
not possible for S4 classes. I would kindly request new
2002 Oct 25
0
[., multiple inheritance, and R 1.6
Matt Nelson <MNelson at sequenom.com> reported a problem using the Hmisc library that did not occur with versions of R before 1.6. I am running
platform i686-pc-linux-gnu
arch i686
os linux-gnu
system i686, linux-gnu
status
major 1
minor 6.0
year 2002
month 10
day 01
language R
> library(Hmisc)
> g <-
2012 Oct 17
1
Do *not* pass '...' to NextMethod() - it'll do it for you; missing documentation, a bug or just me?
Hi,
although I've done S3 dispatching for more than a decade now, I think
I managed to overlook/avoid the following pitfall when using
NextMethod():
If you explicitly pass argument '...' to NextMethod(), you will
effectively pass those argument twice to the "next" method!
EXAMPLE:
foo0 <- function(...) UseMethod("foo0");
foo1 <- function(...)
2004 Oct 28
1
Another problem with next method
I have another problem with NextMethod. Not sure if its related
to the last problem.
In this example, we have a generic called ff with methods
for AsIs and test classes. We call the generic with an
object of AsIs class. The corresponding method adds 1 to it
and then changes the class to test followed by issuing a
NextMethod. However, that results in this error (using R
2.0.0, 2004-10-04
2010 Feb 14
1
NextMethod() example from S Programming by Venables and Ripley (page 78)
S Programming by Venables and Ripley (page 78) has the example listed
at the end of this email. However, I get the following error when I
try the example. I don't understand the descriptions of NextMethod on
its help page. Could somebody let me know how to fix the error of this
example?
> test(x)
c1
c2
Error in NextMethod() : no method to invoke
Calls: test -> test.c1 -> NextMethod
2018 Feb 22
2
How to modify dots and dispatch NextMethod
The example is invoking NextMethod via an anonymous function, which is
not allowed (see documentation for NextMethod). Normally one gets a
runtime error "'NextMethod' called from an anonymous function", but not
here as the anonymous function is called via do.call. I will fix so that
there is a runtime error in this case as well, thanks for uncovering
this problem.
I
2018 Feb 22
2
How to modify dots and dispatch NextMethod
On 02/22/2018 12:07 PM, I?aki ?car wrote:
> 2018-02-22 10:29 GMT+01:00 Tomas Kalibera <tomas.kalibera at gmail.com>:
>> The example is invoking NextMethod via an anonymous function, which is not
>> allowed (see documentation for NextMethod).
> Thanks for your response. I definitely missed that bit.
>
>> Normally one gets a runtime
>> error
2019 Nov 01
4
[External] R C api for 'inherits' S3 and S4 objects
Thank you Luke.
That is why I don't use Rf_inherits but INHERITS which does not
allocate, provided in the email body.
I cannot do similarly for S4 classes, thus asking for some API for that.
On Fri, Nov 1, 2019 at 5:56 PM Tierney, Luke <luke-tierney at uiowa.edu> wrote:
>
> On Fri, 1 Nov 2019, Jan Gorecki wrote:
>
> > Dear R developers,
> >
> > Motivated by
1999 Apr 16
1
NextMethod
>> One clear moral seems to be don't do anything more inside a
>> generic function than you really need to do. Keep it *very*
>> simple indeed.
>>
> I recall JMC saying something like, all generic functions
> should be one line long; a call to the appropriate UseMethod.
It certainly is encouraging to know that others also have been confused by
aspects of
2011 Nov 18
1
S4 : defining [<- using inheritance from 2 classes
Hi the list,
I define a class 'C' that inherit from two classes 'A' and 'B'. 'A' and 'B'
have no slot with similar names.
----------------
setClass(
Class="C",
contains=c("A","B")
)
To define the get operator '[' for class "C", I simply use the get of "A" or
"B" (the constante
2010 Jun 13
1
S4 classes and S3 generic functions
A general goal for the next version of R is to make S4 and S3 play
better together.
As mentioned in a previous thread, one limitation has been that S3
generic functions, specifically the UseMethod() call, did not make use
of S4 inheritance when dispatching on general S4 objects.
This has been fixed in a version committed today (updated to rev 52267).
The code change is not large, but it
2019 Aug 07
1
NextMethod() and argument laziness
Hi all, I'd like to ask if the following behavior is a bug. To me it
certainly feels surprising, at the very least. In this example, I would
like to call NextMethod() from my `child` object, have `cols` be left
untouched, and then substitute(cols) in the parent method. It works when
you use a `parent` object (as expected), but I would have also expected to
get `mpg` back when calling it from
2006 May 18
3
S4 classes and C
Is there any good source of information on how S4 classes (and methods)
work from C?
E.g., for reading
how to read a slot value
how to invoke a method
how to test if you have an s4 object
For writing, how to make a new instance of an S4 object.
I've found scattered hints in the archive, including a link to a talk on
this subject "I am using C code to create an S4 object based on
2018 Feb 20
2
How to modify dots and dispatch NextMethod
Hi all,
Not sure if this belongs to R-devel or R-package-devel. Anyways...
Suppose we have objects of class c("foo", "bar"), and there are two S3
methods c.foo, c.bar. In c.foo, I'm trying to modify the dots and
forward the dispatch using NextMethod without any success. This is
what I've tried so far:
c.foo <- function(..., recursive=FALSE) {
dots <-
2006 Apr 14
3
The object argument of NextMethod.
My question is when the object argument of NexthMethod be used?
In the following example, weather object argument is used will not
affects the result.
###
foo=function(x) {UseMethod("foo")}
foo.cls1=function(x)
{
x=x+1;class(x)<-"ncls"
NextMethod()
}
foo.ncls=function(x)
{
cat("ncls\n")
}
foo.cls2=function(x)
{
cat("cls2\n");print(x)
}