search for: useasdefault

Displaying 20 results from an estimated 20 matches for "useasdefault".

Did you mean: use_default
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")
2006 Oct 19
1
default arguments in generics and methods
...call to 'standardGeneric', then the method for signature (..., ARG = class (ARG), ...) will be called, with the assigned value of ARG passed to the call. this behavior is exhibited by the code below: __ setGeneric("foo", function(x = 1) standardGeneric("foo"), useAsDefault = FALSE) setMethod("foo", signature(x = "missing"), function(x = 3) x) setGeneric("foo2", function(x = 1) {x; standardGeneric("foo2")}, useAsDefault = FALSE) setMethod("foo2", signature(x = "missing"), function(x = 3) x) setGeneric(&qu...
2006 Oct 11
1
dispatching on group generics with more than one formal
...n should not be called directly. __ setGroupGeneric("Foo", function(x) standardGeneric("Foo")) setGroupGeneric("Foo2", function(x, y) standardGeneric("Foo2")) setGeneric("foo", function(x) standardGeneric("foo"), group = "Foo", useAsDefault = function(x) "Default") setGeneric("foo2", function(x, y) standardGeneric("foo2"), group = "Foo2", useAsDefault = function(x, y) "Default2") setMethod("Foo", signature(x = "numeric"), function(x) "Special") setMethod(...
2004 Feb 26
2
package 'stats' needs import directive for 1.9.0?
I maintain the Irregular Time Series (its) package on CRAN. I am currently testing a release. Under 1.8.1 I am able to define a S4 generic 'start' as follows: if(!isGeneric("start")) {setGeneric("start", useAsDefault=start)} Under 1.9.0, Rcmd check generates an error, as 'start' is not recognised. If I use the NAMESPACE directive IMPORT, all is well: import(stats) (I recall some past postings about refactoring 'base', and I assume that 'stats' is a part of this) However, the addition...
2004 Jan 08
3
S3, S4, namespace
...This all works fine - the problem occurs when I try to import the method to another package. Here is the bit that works fine. ------------- #the .r file for package bar setClass("bar",representation("numeric")) if(!isGeneric("print")) {setGeneric("print",useAsDefault=print)} setMethod("print",signature(x="bar"), print.bar <- function(x,...) { print("print method for bar") print(x@.Data,...) } ) if(!isGeneric("barprint")) {setGeneric("barprint",useAsDefault=print)} setM...
2006 Mar 17
0
setMethod bug
...n that has many parameters (~20). I then want to define methods for the generic function with setMethod. The default behavior for setGeneric is to allow dispatching on any argument in the def function, expect ... For example, # define a generic function setGeneric("test", useAsDefault=FALSE, function(a,b,c,d,e,f,g,h,i,j,k,l,m,n, o,p,q,r,s,t,u,v,w,x,y,z,...){ standardGeneric("test") } ) # If I define a method for an argument early in the list of arguments, then there is no problem......
2008 May 20
1
S4 generic for lowess
Hi, A lowess method is defined in our package for one of our S4 classes. To explicitely define the generic this is being used if (!isGeneric("lowess")) setGeneric("lowess", useAsDefault = lowess) This works fine for many other methods inherited from various R packages. In this case a warning is issued in R CMD check: * checking R code for possible problems ... NOTE lowess: no visible binding for global variable ?xy? lowess: no visible binding for global variable ?o? which I ass...
2012 Nov 21
1
S3 generic/method consistency issue with R CMD check
Hi, I'm having some trouble setting methods for the qr family of functions. I believe I have distilled my misunderstanding in the code snippet below: foo <- function(x, ...) UseMethod("foo") foo.default <- function(x) { } # foo setGeneric(name = "foo", useAsDefault = foo) setMethod("foo", signature(x="bar"), function(x, ...) { } ) setGeneric(name="foo.Q", function(y, ...) standardGeneric("foo.Q") ) setMethod("foo.Q", signature(y="bar"), function(y, ...) { } ) # QR setGeneric(name = &qu...
2010 Jan 11
1
Problem with S4 generic function print
...ng letter() without return('\n') to console. It seems bizarre... System is Mac OS X 10.5.8 (PowerPC) R 2.9.1 GUI 1.28 Tiger build 32-bit (5444) R version 2.9.1 (2009-06-26) Minimal amount of code to get the behaviour is if(!isGeneric("print")) {setGeneric("print",useAsDefault=print)} What is the underlying problem? Sven Laur
2011 Jun 01
1
Overloading S4 methods
Dear all, I am experiencing some problems with S4 method overloading. I have defined a generic for graphics:plot, using setGeneric("plot", useAsDefault = plot) and with importFrom('graphics', 'plot') and exportMethods('plot') in the NAMESPACE file of pkg A. I then proceed to define a method for signature c('myS4class', 'missing'). This works as expected: selectMethod('plot', c('myS4class'...
2009 Nov 04
1
s4 generic issue
...to say virtually everyone reading this list, could help resolve the following problem in SparseM. We have setGeneric("backsolve", function(r, x, k = NULL, upper.tri = NULL, transpose = NULL, twice = TRUE, ...) standardGeneric("backsolve"), useAsDefault= function(r, x, k = ncol(r), upper.tri = TRUE, transpose = FALSE, twice = TRUE, ...) base::backsolve(r, x, k = ncol(r), upper.tri = TRUE, transpose = FALSE, ...)) and then proceed to use setMethod for a class matrix.csr.chol. However,...
2007 Mar 15
4
R 2.5.0 devel try issue in conjuntion with S4 method dispatch
...ed = TRUE, ) if (!isGeneric("plotObject")) { setGeneric("plotObject", def=function(x, y, ...) { value <- standardGeneric("plotObject") return(value) }, where=.GlobalEnv, useAsDefault=TRUE ) } setClass("foo", representation("fooBase"), validity = NULL, where = .GlobalEnv, sealed = TRUE) plotObject.foo <- function(x, y) { plot(x,y) } setMethod("plotObject", signature=c("foo", &q...
2008 Feb 24
2
Generic Functions
Hi I have some problems in defining new generic functions and classes. Just have a look at the following example: require(fPortfolio) setClass("PROBECLASS", representation( type="character" ) ) isGeneric("setType<-") #Returns TRUE #I would like to define a specific function for
2008 Feb 24
2
Generic Functions
Hi I have some problems in defining new generic functions and classes. Just have a look at the following example: require(fPortfolio) setClass("PROBECLASS", representation( type="character" ) ) isGeneric("setType<-") #Returns TRUE #I would like to define a specific function for
2005 Oct 14
1
extending lattice to S4 classes
Hi, I'm writing methods for a package called FLCore (see http://flr-project.org/) in particular for a class called "FLQuant" which extends array. Previously I was able to write methods based on the class of "data" but now I can not do it due to the single parameter "x". Is there a way to do this ? Regards EJ
2011 Jan 13
1
s3 methods on S4 objects
I have J Chambers wonderful text ( Software for data Analysis) and I've been trying my hand at some very routine S4 OOP development. One of the things I was trying to do was to create some very basic S4 classes. The first was simply a class that had a data.frame as part of its representation. setClass("df",representation(dirframe="data.frame")) The object basically
2006 Sep 04
1
setMethod("Summary")
Hi everyone and thanks for being patient. I've used "!.foo"() et seq pro tem. Next problem: how to define "Summary" methods for brobs. ?max says 'max' and 'min' are generic functions: methods can be defined for them individually or via the 'Summary' group generic. For this to work properly, the arguments '...' should be
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
2007 Oct 03
1
R-2.6.0 is released
...eric versions of functions in R core are consistent. See ?implicitGeneric. o Error messages generated by some of the functions in the methods package provide the name of the generic to provide more contextual information. o It is now possible to use setGeneric(useAsDefault = FALSE) to define a new generic with the name of a primitive function (but having no connection with the primitive). DEPRECATED & DEFUNCT o $ on an atomic vector now gives a warning that it is 'invalid'. It remains deprecated, but may be removed in R &gt...
2007 Oct 03
1
R-2.6.0 is released
...eric versions of functions in R core are consistent. See ?implicitGeneric. o Error messages generated by some of the functions in the methods package provide the name of the generic to provide more contextual information. o It is now possible to use setGeneric(useAsDefault = FALSE) to define a new generic with the name of a primitive function (but having no connection with the primitive). DEPRECATED & DEFUNCT o $ on an atomic vector now gives a warning that it is 'invalid'. It remains deprecated, but may be removed in R &gt...