similar to: R.oo question

Displaying 20 results from an estimated 1500 matches similar to: "R.oo question"

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 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 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
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 Mar 10
1
getting percentiles by factor
Hello, I'm trying to get percentiles (PERCENTRANK for excel users) by factor in the following data.frame: myExample <- data.frame(Ret=seq(-2, 2.5, by=0.5),PE=seq(10,19),Sectors=rep(c("Financial","Industrial"),5)) myExample <- na.omit(myExample) Thanks to Patrick I I managed to put together the following lines which does it for the "Ret" column: myecdf
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 May 18
1
difficulties with setMethod("[" and ...
Apologies if I am not understanding something about how things are being handled when using S4 methods, but I have been unable to find an answer to my problem for some time now. Briefly, I am associating the generic '[' with a class which I wrote (here: myExample). The underlying back-end allows me to read contiguous slabs, e.g., 1:10, but not c(1, 10). I want to shield the user from this
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),
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 Oct 27
0
R.oo package, inherit two classes
Hello, How do I inherit two classes using the R.oo package. Below is kind of a silly example, but I am trying to create class PerDog from classes Dog and Person. Error at bottom. I've tried a few other ways of using extend(), but nothing seems to get me what I want. Example: setConstructorS3("Person", function(age=NA) { this = extend(Object(), "Person", .age=age )
2012 Jun 26
5
Next Problem: Puppet 2.7 + Passenger won't connect
OK. What did I booger up this time ? agent.myexample.org and puppetmaster.myexample.org are the same server. ---------------------------------------------------------------------------- # puppetd --no-daemonize --onetime --debug --noop debug: Puppet::Type::User::ProviderUser_role_add: file roleadd does not exist debug: Puppet::Type::User::ProviderDirectoryservice: file /usr/bin/dscl does not
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
2009 Feb 20
2
importing data to SQLite database with sqldf
Hi all, I am attempting to learn SQL through sqldf... One task I am particularly interested in is merging separate (presumably large) files into a single table without loading these files into R as an intermediate step (by loading them into SQLite and merging them there). Taking a step back, I've considered these alternatives: 1) I know if I use straight SQLite commands I might use the
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 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]]
2005 Oct 27
3
its dates masked by chron
I built R 2.2.0 from source on my debian machine yesterday and updated all packages. My problem is that "dates" function from its, that my code heavely uses is now masked by "dates" from chron. How can I specify tehat I want to use dates from its or how can I prevent it from being masked? > library(its) Loading required package: Hmisc Hmisc library by Frank E Harrell Jr
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
2006 Apr 10
3
timeAlign
I use POSIXct for datetimes. Is thee a timeAlign function that I can use where : align by year direction -1 ==> start of this year direction 1 ==> start of next year align by week direction -1 ==> date on last sunday direction 1 ==> date on next sunday align by day direction -1 ==> time at past midnight direction 1 ==> time at this comming