similar to: efficiency and memory use of S4 data objects

Displaying 20 results from an estimated 10000 matches similar to: "efficiency and memory use of S4 data objects"

2017 Sep 22
2
S4 method implementation for S3 class
Hi all, I'm trying to implement the matrix multiplication operator, which is S4 generic, for an old-style S3 class. The following works as expected: x <- 1:10 class(x) <- "myClass" setOldClass("myClass") setGeneric("myMethod", function(x, y) standardGeneric("myMethod")) setMethod("myMethod", c("myClass", "myClass"),
2005 Jun 02
1
showMethods doubt
Hi, I'm developing in S4 and I wanted to see the methods for a specific class using showMethods but I didn't succed. Can someone help ? See the example below. setClass("myclass", representation( name ="character" ) ) setGeneric("mymeth", function(obj, ...){ standardGeneric("mymeth") } ) setMethod("mymeth",
2005 Dec 07
1
Dots argument in apply method
Hello everyone, I'm working on a package using S4 classes and methods and I ran into the following "problem" when I tried to create an "apply" method for objects of one of my new classes. I've found a way around the problem but I wonder if I did not paint myself into the corner. I'd like your opinion about that. So I have an object "myObj" of class
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
2003 Dec 02
1
setMethod("min", "myclass", ...)
Hello, I have defined a new class > setClass("myclass", representation(min = "numeric", max = "numeric")) and want to write accessor functions, so that for > foo = new("myclass", min = 0, max = 1) > min(foo) # prints 0 > max(foo) # prints 1 At first i created a generic function for "min" > setGeneric("min",
2014 Jan 07
1
Why do methods of "initialize" have no "srcref" attribute as other S4 mehtods?
For documentation we use a system that generates Rd files from special comments in the code. (inlinedocs). It is crucial to be able to get the defining source code for objects like methods to extract the comments from it. Here is an R session that shows how this works for several kinds of methods and (at the end of the session) how if fails for methods of "initialize" >
2011 Jun 29
1
Ref Classes: bug with using '.self' within initialize methods?
Dear list, I'm wondering if the following error I'm getting is a small bug in the Reference Class paradigm or if it makes perfect sense. When you write an explicit initialize method for a Ref Class, can you then make use of '.self' WITHIN this initialize method just as you would once an object of the class has actually been initialized? Because it seems to me that you can not.
2004 Jun 26
1
S4 group "Math", "getGroupMembers", "genericForPrimitive"
Hi, I found the following on Windows 2000/NT R Version 1.9.1 (2004-06-21) (also Version 1.9.0): The S4 group "Math" doesn't work as documented; i.e., "log", "log10", "gamma" and "lgamma" are included in the documentation but don't work. See example code below. Moreover, what about 'genericForPrimitive' which is used in
2008 Dec 22
1
How to add a slot to S4 class of an existing package?
Dear all, Since my package is based on S4 classes, I would like to know how to add a slot to an existing S4 class without breaking the code of users of my package. Assume the following S4 class: setClass("MyClass", representation(name = "character", type = "character", data = "data.frame" ), prototype(name =
2004 Nov 11
1
"<<-" assignment no long work in class methods
Hi- I used to use "<<-" to do assignment inside a class method, and just found that now it is broken in R 2.0. For example, the following code ----------------------------------------------------------------------- setClass( "myclass", representation(x="numeric") ) setGeneric("incrXByOne", function(obj) standardGeneric("incrXByOne"))
2007 Mar 30
2
Replacing slot of S4 class in method of S4 class?
Dear all, Assume that I have an S4 class "MyClass" with a slot "myname", which is initialized to: myname="" in method("initialize"): myclass <- new("MyClass", myname="") Assume that class "MyClass" has a method "mymethod": "mymethod.MyClass" <- function(object, myname=character(0), ...) {
2008 Apr 07
3
Overriding axis formatting with custom Axis method, Axis.numeric etc
Dear list: I would like to override the default way R formats plot axes with a custom method(s). Obviously I would prefer to define it as general as possible avoiding writing a custom method for each individual class where possible. The plot.default method (and I assume other methods as well) calls Axis(...) to produce the axis layout depending on data. In this sense it seems reasonable to
2004 Sep 07
2
as(object,"list") as(object,"matrix") differences?
Hello! as(object,"list") and as(object,"matrix") behave quite differently if it comes to their attributes. I define two classes. One of them "contains" a "list" the other a "matrix" setClass("myclass" ,representation(info="character") ,contains="matrix" ) setClass("mylist"
2009 Jan 02
1
"registering" a generic method for a class
Sorry in advance if this is too simple a question, but I'm stuck with some odd behavior and I can't find the text to rid myself of this (admittedly somewhat trivial) problem. Note that I've done generic programming with S3 "objects" in the past, but I've never really dabbled in creating S4 objects until now. So, I've created a new S4 class, call it
2003 Jul 23
1
S3 and S4 classes
Hi helpers, I've been programming in R for a few months now but I still have doubts about my code - I would like it to be completely S4-compatible. The current code works fine but is probably 'unclean'. I read the interesting article in the last R News and it helped me understand the difference on the whole between S3 and S4 classes, but I need a practical example. Could anyone
2002 May 08
1
Questions about S4 style methods and generics
I have some questions about S4 style methods and generics. First of all, is there any way of using default values for arguments in the generics/methods? My own experiments show that such arguments are always ignored. The green book seems to be silent on this matter. The second question is about using a non-trivial function body for generics. Page 351 of the green book gives an example of this
2003 Jul 09
2
Packages, generics, S3 and S4
My question has two parts. The first is with regard to the frame or environment in which generic functions are defined in packages. It seems as though they are defined (i.e. exist as objects) in frame 1, even when defined in a package. The following is a short example: setClass("track",representation(x="numeric",y="numeric")) plotTrack <- function(x,y,...)
2002 Dec 30
2
Writing packages with `methods' package
I'm trying to write a package which uses classes/methods as defined in the `methods' package. I have a single .R file which defines the class and various methods for that class. At the top of the file I have require(methods) and then setClass("myclass", ...) setGeneric("intersect") setMethod("intersect", "myclass", function(x,y) ...) I noticed
2004 Sep 03
2
debugging an S4 method
Does anyone know how to use the equivalent of debug() on an S4 method? I would like R to enter the browser not for the generic function, but for the method of the class that I specify. Thanks, David _____________________________ David Bickel http://davidbickel.com Research Scientist Pioneer Hi-Bred International Bioinformatics & Exploratory Research 7250 NW 62nd Ave., PO Box 552 Johnston,
2005 Aug 05
1
S4 setClass with prototypes " issues" (PR#8053)
To R-Developers: I wish to report what I believe are inconsistencies between Green Book descriptions and R methods behaviors. I **realize** that R does not guarantee total consistency with the Green Book; therefore I leave it to you to decide whether any of this is a bug, design choice, or a need for additional documentation -- or whether I have simply misread or overlooked existing explanations.