similar to: R.oo package, inherit two classes

Displaying 20 results from an estimated 300 matches similar to: "R.oo package, inherit two classes"

2011 Aug 26
0
R.oo inheritance with pass by reference
I thought I would post an example of using R.oo with inheritance and pass by reference for future searches. With PerMore I am inheriting Person. Then I am changing an object data memeber of an object of PerMore class using pass by reference ('mimiced' by R.oo) in an object of AgeMultiplier. I change a data member in the child class and the parent class for demonstration purposes. This is
2011 Oct 24
0
R.oo package: do setMethodS3 work upon construction
Hello (Heinrich), I did not know I could do this. It doesn't seem to be documented anywhere. Thought this would be helpful to the fraction of the community using package R.oo. Note the call of a setMethodS3 method, xOne, in the setConstructorS3. This is extremely useful if xOne (in this case) is a very complex method (that you always want to be called every time you create a new object). If I
2011 Aug 26
1
R.oo data members / inheritance
If someone is able, can you tell me if there is a better way to do this? More specifically, do I have to rewrite all of the data members stuff and extend stuff of parent class in the child class? See below. Thanks in advance! Example 1: setConstructorS3("ClassA", function(A,x) { if(missing(A))A=15; if(missing(x))x=NA; extend(Object(), "ClassA", .size = A, .x=x
2008 Nov 05
1
Methods dispatch and inheritance R.oo
Hi to all members, i have a question about class inheritance and methods using R.oo package: I have the following code and it doesn't work, guess i'm doing smth wrong and there is nothing in the help. library(R.oo) setConstructorS3("ClassA", function(A=15) { extend(Object(), "ClassA", .size = A ); }) setMethodS3("print", "ClassA",
2011 Sep 22
1
R.oo: do work on data member at construction
Hello, I'd like to 'do work' on data members upon construction (i.e. without implementing it in a get method). Is this the best way to create data member 'z' upon construction? I'm thinking if .z=paste(x,y) below gets more complex I'll run into issues. setConstructorS3("MyClass", function(x=NA,y=NA,...) { this <- extend(Object(), "MyClass",
2011 Aug 18
0
Call super methods from inherited classes R.oo
Hi R-community, I'm very busy with a software project which I would like to development completely with R.oo. Many of the object oriented aspects that I already know from Java development seems to be in place with this library. But...there is something that I'm really missing... *the super method call* Just a little example that shall demonstrate what I mean: Image we have the following
2011 Jun 16
1
Question about R.oo package
Dear R.oo package users, while testing some functionality of the R.oo, I found that during the first construction of a object from a class, the constructor is twice called, but only one object is finalized. In all subsequent creation processes, the constructor is (expectedly) called once. Here some example code: library(R.oo) setConstructorS3("Test_class",function(val) {
2011 Aug 23
1
R.oo modify an object inside another classes method
Can someone show me how to modify one (R.oo) class's object inside another (R.oo) class's method? Is that possible with the R.oo package? A quick example or reference to an example would be outstanding... Thanks, Ben [[alternative HTML version deleted]]
2003 Oct 27
1
Difficulties with R.oo (static fields, etc.)
I would like to use R.oo and tcltk to implement a Turtle World. I have encountered many problems because: 1) I am not sure how to implement static fields with R.oo 2) I am not sure how to implement a constructor that would call a function only for the first instance of a class (i.e., to initialize value of static fields only once) 3) I am not sure how to remove/delete cleanly existing
2008 Oct 24
1
Help regarding oo package
Hi Henrik, I'm sorry to be bothering you, but there is something that I have been stuck with for a while now. I am trying to create a class like : setConstructorS3("MyPTCM",function(tokenslist=0) { extend(Object(), "MyPTCM", .gamma = 0.0, .rho = 0.0, .phi = 0.0, .tokenslist = tokenslist, .uniquetokens = unique(tokenslist),
2007 Dec 17
0
Extending data.frame
Hi, I've got a long-running project whose data fits nicely into data.frame objects in R. As I accumulate more and more functions, I decided to switch to an OO approach so I can organize things better. Looking around at the various approaches to OO R, I came across R.oo, which seems nice. Where I'm currently stuck is getting my objects to be mutable. For example, in the following toy
2009 Jul 17
1
Help with R.oo
Hi! I'm trying to learn about object oriented R, as it seems like it would be very useful. I'm going over an example from the documentation, and I'm very confused: http://www1.maths.lth.se/help/R/R.oo/ [assume you've called library (R.oo)] setConstructorS3("SavingsAccount", function(balance=0) { if (!is.numeric(balance) && length(balance) != 1)
2011 Aug 08
1
R.oo error upon construction
Hello, Using the R.oo package, how do I throw an error if a field is not present when the user of the class creates the object? Using the example in the R.oo package: setConstructorS3("Person", function(name, age) { if (missing(name)) name <- NA; if (missing(age)) age <- NA; extend(Object(), "Person", .name=name, .age=age ) }) [rest of class methods
2006 May 26
1
R.oo question
This is a simple R.oo question but I, thankfully, hope that someone would explain it to me so I would better understand this work frame. I create this class: setConstructorS3("MyExample", function(param=0) { print(paste("called with param=", param)) extend(Object(), "MyExample", .param = param ); }) >From what is printed out, who made the second call to
2008 Dec 10
1
First call to constructor fails (R.oo)
Hi all, I'm trying to do some object-oriented programming in R using the R.oo package. Right from the start I encountered a strange (at least for me) problem. I define a new class/constructor based on the R.oo documentation. However the first attempt to create an object fails: === Code: === library(R.oo); setConstructorS3("MyClass",function(param) { print(param);
2005 Jul 08
2
R.oo static field
How can I define a static member of a class? not a static method, rather a static field that would be accessed by all instances of the class.
2010 Jan 20
1
R.oo installation warnings?
I got the following warnings when I install R.oo. Are these warnings normal? Should I reinstall the package as mentioned in the warnings? How to reinstall? The sessionInfo() is at the end. > install.packages("R.oo", dependencies=T) Warning in install.packages("R.oo", dependencies = T) : argument 'lib' is missing: using '/utility/R' also installing the
2007 Jan 17
3
R.oo Destructors
Has anyone figured out how to create a destructor in R.oo? How I'd like to use it: I have an object which opens a connection thru RODBC (held as a private member) It would be nice if the connection closes automatically (inside the destructor) when an object gets gc()'ed. Thanks in advance. Regards, Ken BTW, a >BIG< thanks to Henrik Bengtsson for creating the R.oo package! Lucky
2008 Mar 06
1
Argument "nomatch" matched by multiple actual arguments ... %in% -> match?!?
When I run R CMD check R.oo on R v2.7.0 devel (2008-03-04 r44677) on WinXP I get the following error while testing examples: Error in match(x, table, nomatch = 0) : formal argument "nomatch" matched by multiple actual arguments Calls: setMethodS3 -> setMethodS3.default -> %in% -> match Execution halted How is that even possible with: > get("%in%") function (x,
2005 Feb 16
0
Depends, require(), autoload() and "side effects"?
Hi. If your package require another package in order to define its methods (but afterwards in is not needed), how should one specify this? Is it correct to assume that "Depends" will assure that all packages are loaded (attached? what is the right word) *before* the methods in the current package are defined? Basically I use my own setMethod() called setMethodS3() that is defined in