search for: setmethods3

Displaying 20 results from an estimated 22 matches for "setmethods3".

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 have something wrong please let me know! (I'm about to implement this in a large'ish program.) Great p...
2011 Aug 26
1
R.oo data members / inheritance
...write 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 ) }) setMethodS3("getSize", "ClassA", function(this,...) { this$.size; }) setMethodS3("getX", "ClassA", function(this,...) { this$.x; }) setConstructorS3("ClassB", function(A,x,bData) { if(missing(bData))bData = NA; extend(ClassA(), "ClassB",...
2011 Aug 26
0
R.oo inheritance with pass by reference
...nd gets rather than obj$dataMember. I am new to R.oo so if you know how to do this better or have some tricks please email me at ccquant@g*m@il.com. setConstructorS3("Person", function(age) { if (missing(age)) age <- NA; extend(Object(), "Person", .age=age ) }) setMethodS3("getAge", "Person", function(this, ...) { this$.age; }) setMethodS3("setAge", "Person", function(this,num, ...) { this$.age = num; }) #.......................................................... setConstructorS3("PerMore", function(age,wt) { if...
2011 Sep 22
1
R.oo: do work on data member at construction
...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", .x=x, .y=y, .z=paste(x,y) ) }) setMethodS3("getX", "MyClass", function(this, ...) { this$.x; }) setMethodS3("getY", "MyClass", function(this, ...) { this$.y; }) setMethodS3("getZ", "MyClass", function(this, ...) { this$.z; }) > mc = MyClass('a','b') > m...
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, table) match(x, table, nomatch = 0) > 0 <environment: namespace:base> All '%in' statements in setMethodS3.default are of kind (foo %in% bar)....
2011 Oct 27
0
R.oo package, inherit two classes
...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 ) this }) setMethodS3("getAge", "Person", function(this, ...) { this$.age; }) setMethodS3("setAge", "Person", function(this,num, ...) { this$.age = num; }) # .......................................... setConstructorS3("Dog", function(dog_age=NA) { this = extend(Obje...
2008 Nov 05
1
Methods dispatch and inheritance R.oo
...lass 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", function(this,...) { print(paste('Class A:',this$.size)); }) objA<-ClassA(); objA [1] "Class A: 15" setConstructorS3("ClassB", function(B=15) { extend("ClassA", "ClassB", .size2 = B ); }) setM...
2003 Oct 27
1
Difficulties with R.oo (static fields, etc.)
...canvas(top, relief="raised", width=200, height=200) tkpack(canvas, side="top", fill="both",expand="1") new$.canvas<-canvas # store canvas widget in static field new$.top<-top } plot.TurtleBasic(new) # plot Turtle new }) setMethodS3("plot","TurtleBasic",function(turtle) { ## delete old item (if it exists) if(is.tkwin(turtle$.canvas) && is.tclObj(turtle$.turtle)) tkdelete(turtle$.canvas,turtle$.turtle) ## a new canvas item representing the turtle is created ## (note: it's nec...
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 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.
2011 Aug 18
0
Call super methods from inherited classes R.oo
...method call* Just a little example that shall demonstrate what I mean: Image we have the following class hierachie that I graped from another post - thx to YuriWerewolf ;-). *ClassA* setConstructorS3("ClassA", function(A) { extend(Object(), "ClassA", .size = A ); }) setMethodS3("print", "ClassA", function(this,...) { print(paste('Class A:',this$.size)); }) *ClassB (inherits ClassA)* setConstructorS3("ClassB", function(B=15) { extend(ClassA(), "ClassB", .something = B ); }) # Now I would like to extend the behavio...
2011 Jun 16
1
Question about R.oo package
...ll subsequent creation processes, the constructor is (expectedly) called once. Here some example code: library(R.oo) setConstructorS3("Test_class",function(val) { cat("constructor\n") if(missing(val)) val<-NA; extend(Object(), "Test_class", .val=val) }) setMethodS3("finalize","Test_class",function(this,...) { cat("destructor\n") }) o<-Test_class(1) rm(o) gc() Is there any explanation for this behaviour? Thanks very much in advance W. Kaisers [[alternative HTML version deleted]]
2010 Sep 07
1
Dispatch method on S3 or S4 class
...that dispatches on the first argument, which can be either an S3 or an S4 class. This is as far as I've gotten. Any suggestions about what to try next ? library(aroma.affymetrix) library(GenomicRanges) setGeneric("analyse", function(x, y, ...) standardGeneric("analyse")) setMethodS3("analyse", "AffymetrixCelSet", function(x, y, z, ...) { x; UseMethod("analyse") } ) setGeneric("analyse") setMethod("analyse", "GRangesList", function(x, y, a, b, c) { x; } ) Thanks, Dario. -----------------------------------...
2010 Jan 20
1
R.oo installation warnings?
...ed the preexisting function getMethods to getMethods.default, which was defined in environment base. Warning in setGenericS3.default(name, envir = envir, validators = validators) : Renamed the preexisting function getClasses to getClasses.default, which was defined in environment base. Warning in setMethodS3.default("throw", "default", function(...) { : Method already existed and was overwritten: throw.default ** help Warning: package 'R.oo' claims to be built under R version 2.10.0 but is missing some help files and needs to be re-installed *** installing help indices **...
2005 Feb 16
0
Depends, require(), autoload() and "side effects"?
...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 package R.oo. In pre R v2.0.0 this could be done adding a require() at the beginning of the package source, but since R v2.0.0 this should be avoided according to R-exts [R v2.1.0 devel] (Section 1.1.4; "The R code files should only create R objects and not call functions...
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),
2009 Oct 26
3
R.oo and S4?
There are different way to make R classes. I know R.oo and S4. I'm wondering which one is the current popular one. Which one is current recommended when make new R packages? Thank you!
2006 Feb 10
1
R CMD build: "Subdirectory 'R' contains invalid file names"
Hi, I get * excluding invalid files from 'R.oo' Subdirectory 'R' contains invalid file names: attachLocally.Object.Rex Exception.Rex extend.default.Rex InternalErrorException.reportBug.Rex Package.Rex Person.Rex Rdoc.Rex setMethodS3.Rex StaticFields.Rex when running R CMD build in R v2.3.0 devel. I do understand what is going on. In my *.R files I keep so called Rdoc comments which in their simplest form are Rd code wrapped up in plain comments. These are compiled into Rd files written to ../man/ (I do this prior to buildi...
2006 Mar 15
1
setMethod confusion -best reference for S4 programming
...R.oo package. Example: library(R.oo) setClass("fSites", representation(x="numeric", y="numeric")) setGeneric("tableS4", function(.Object, ...) standardGeneric("tableS4")) setMethod("tableS4", "fSites", function(.Object) .Object) setMethodS3("table", "fSites", function(.Object, ...) tableS4(.Object, ...)) Test; > x <- new("fSites") > table(x) An object of class "fSites" Slot "x": numeric(0) Slot "y": numeric(0) > X <- rpois(20, 1) > table(X) X 0 1 2 3...
2007 Dec 17
0
Extending data.frame
...ample, in the following toy code, the addStuff() method has no effect: > library(R.oo) R.oo v1.3.0 (2006-08-29) successfully loaded. See ?R.oo for help. > setConstructorS3("Foo", function(...) { + frame <- data.frame(foo=4, bar=3:5) + extend(frame, "Foo") + }) > setMethodS3("addStuff", "Foo", function(this, ...) { this$field <- 5 }) > f <- Foo(); f foo bar 1 4 3 2 4 4 3 4 5 > addStuff(f); f foo bar 1 4 3 2 4 4 3 4 5 Can anyone offer any advice? I'm open to using a different OO system if that's deem...