similar to: S4 Methods with large numbers of args using memory

Displaying 20 results from an estimated 20000 matches similar to: "S4 Methods with large numbers of args using memory"

2006 Feb 14
3
S4 classes and methods with optional arguments
Hi, i have used S4 classes to implement a unified access to random number generators (package rstream on CRAN). I have used a construct to allow optional arguments: if(!isGeneric("rstream.sample")) setGeneric("rstream.sample", function(stream,...) standardGeneric("rstream.sample")) setMethod("rstream.sample",
2005 Mar 25
1
S4 methods semantics questions
Some quick questions about S4 methods. Does the typing of S4 methods mean that lazy evaluation is no longer possible? It seems that you would need to evaluate the arguments to determine their type at dispatch. Second, what role, if any, do default arguments play in S4 methods? I notice that you can put default arguments into generics but that the dispatch is still done on the type of the
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
2005 Dec 29
1
trouble with S4 methods for group "Summary"
Hello. This question concerns the Methods package. I have created a new class and am trying to set a method for it for S4 group generic "Summary". I have run into some signature problems. An example: > setClass("track", representation(x="numeric", y="character")) [1] "track" > setGeneric("max", group="Summary")
2010 Oct 26
1
S4 methods for rbind()
Hello. I am trying to write an S4 method for rbind(). I have a class of objects called 'mdm', and I want to be able to rbind() them to one another. I do not want the method for rbind() to coerce anything to an mdm object. I want rbind(x1,x2,x1,x2) to work as expected [ie rbind() should take any number of arguments]. This is what I have so far: setGeneric(".rbind_pair",
2011 Nov 09
1
Define S4 methods for 'plot'
Hi the list I am creating a package and I have a problem to define a S4 method for plot. I define a class 'A' and a class 'B'. I want to define a function plot for signature c(A,missing) and another method plot for signature c(A,B). My code is the following : In /package/R/ directory: --- main.R --- setGeneric("plot",function(x,y,...){standardGeneric("plot")})
2010 May 14
1
S4 default/missing args
I am trying to understand the missing vs default value for an argument to an S4 method. (I'm not sure if this is a bug or my confusion.) In S3 I can specify a default value for an argument and then both check if the argument was missing in the call, and use it because it takes on the default value. I do not seem to be able to do that in S4 as shown by this simplified example:
2009 Oct 14
1
Cacheing computationally expensive getter methods for S4 objects
Hi, I was wondering if there was a way to store the results of a computationally expensive "getter" call on an S4 object, so that it is only calculated once for each object. Trivial example: let's say I want to cache the "expensive" area calculation of a square object. setClass("Square", representation( length='numeric',
2009 Aug 05
1
S4 method dispatch: coercion of arguments with setAs defined
Hi list, I've got a class B that contains a slot obj of class A. I'd like to be able to call all the methods of class A directly on objects of class B as if I had called the method on slot obj. This without overloading all methods of class A to work on class B. I don't define B as an extension of A, because I want class B to also work with objects of classes that inherit from
2010 Jul 21
1
Bug: broken exception handling in S4 methods
Hi all: we have noticed for quite a while that certain errors cannot be handled by R try, tryCatch etc blocks, but it was fairly difficult to understand what were the conditions for this incorrect behaviour. Finally I stabbed across a very understandable case, which is outlined in the (runnable) example below. The main message is: wrapping an S4 method call in a try block will not help if an
2010 Sep 03
3
S4 Method Signatures
Hello, If the signature of a method defines which generic it implements then I'm confused about why this minimal example I invented won't work : setGeneric("myFun", function(rs, ...){standardGeneric("myFun")}) setGeneric("myFun", function(cs, ...){standardGeneric("myFun")}) setMethod("myFun", "numeric", function(rs, colour =
2006 Jan 25
2
Using substitute from inside an S4 method
Hi all, I would like to access the name of a variable passed to an S4 method. For a function, I would do this: f <- function(x) as.character(substitute(x)) This also works for a the examples I have tried for methods that do not have extra, non-dispatch args: setGeneric("A", function(x, ...) standardGeneric("A")) setMethod("A",
2012 Feb 04
1
'deparse(substitute'))' then 'assign' in a S4 methods
Hi the list, I am writing a function in which I need to affect a variable on a higher level. My fnction could be: ++++++++++++++++++ fooBis <- function(x){ nameObject <- deparse(substitute(x)) print(nameObject) assign(nameObject,4,envir=parent.frame()) } > fooBis(e) [1] "e" > e [1] 4 ----------------- (to simplify, this fnction can affect only the number
2010 Mar 15
2
Strange behavior of assign in a S4 method.
Hi the list, I define a method that want to change an object without assignation (foo(x) and not x<-foo(x)) using deparse and assign. But when the argument of the method does not match *exactly* with the definition of the generic function, assign does not work... Anything wrong? Christophe #------ Does not work ------#
2004 Sep 28
2
S4 method selection based on second argument
I'm translating some Matlab code and need some help figuring out how to change this call into an S4 generic method. In matlab, there's a function called 'repmat' with three calling sequences (all I have to deal with anyway): 1) B = repmat(A, m, n) 2) B = repmat(A, [m n]) 3) B = repmat(A, n) In all cases, A is the fill value, m is number of rows, and n is number of
2004 Apr 19
3
How to write an S4 method for sum or a Summary generic
If I have a class Foo, then i can write an S3 method for sum for it: >setClass("Foo",representation(a="integer"));aFoo=new("Foo",a=c(1:3,NA)) >sum.Foo <- function(x,na.rm){print(x);print(na.rm);sum(x at a,na.rm=na.rm)} >sum(aFoo) But how do I write an S4 method for this? All my attempts to do so have foundered. For example
2012 Apr 12
1
R-2.15.0 and Exporting Methods Converted To S4 Generic
Late to the show on this release, unfortunately. One of our production packages no longer builds under R-2.15.0 with the following message. ** testing if installed package can be loaded Error: Function found when exporting methods from the namespace 'SuperCurve' which is not S4 generic: 'image' Possibly relevant clues follow: ## From R/AllGenerics.R if
2013 Nov 29
1
How to catch warnings sent by arguments of s4 methods ?
Hello, I apologized if this had already been addressed, and I also submitted this problem on SO: http://stackoverflow.com/questions/20268021/how-to-catch-warnings-sent-during-s4-method-selection Example code: setGeneric('my_method', function(x) standardGeneric('my_method') ) setMethod('my_method', 'ANY', function(x) invisible())
2010 Sep 07
1
Dispatch method on S3 or S4 class
Hello, I've been attempting to make a generic method 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",
2007 Mar 15
4
R 2.5.0 devel try issue in conjuntion with S4 method dispatch
Hi, after updating R 2.5.0 devel yesterday we today observed many new unexpected failures in our daily package build and test system runs, which can be traced to recent changes in the implementation in try() (as noted in NEWS). Investigating this new implementation I come across an issue in conjuntion with using S4 classes and methods. try(expr) does not return an object with attribute