search for: isgeneric

Displaying 20 results from an estimated 54 matches for "isgeneric".

2003 Sep 27
2
does isGeneric work differently in 1.8.0 ?
Hello, the last command (isGeneric) in following R-code (attached) produces different output, depending on wheter 1.8.0 alpha or 1.7.1 is used. Is that to be expected ? Both R Versions were started with option vanilla --------------------------------------------------- R.1.7.1: ---------------------------------------------------...
2012 Mar 07
1
isGeneric() can return an error
Hi, I wonder if this is a feature or a bug: > isGeneric("&&") Error in genericForPrimitive(f) : methods may not be defined for primitive function ?&&? in this version of R > isGeneric(":") Error in genericForPrimitive(f) : methods may not be defined for primitive function ?:? in this version of...
2009 Feb 25
1
Unexpected side effect of the ":::" operator on the value of isGeneric
...0x205cee0> Methods may be defined for arguments: object Use showMethods("annotation") for currently available ones. > showMethods("annotation") Function "annotation": <not a generic function> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It seems that the value of isGeneric("annotation"), when it is called within showMethods, is FALSE, while it is TRUE when called outside. > sessionInfo() R version 2.9.0 Under development (unstable) (2009-02-25 r48007) x86_64-unknown-linux-gnu locale: LC_CTYPE=it_IT.UTF-8;LC_NUMERIC=C;LC_TIME=it_IT.UTF-8;LC_COLLATE=it...
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", c("rstream","numeric"), function(stream,n=1) { ... [ code ] ... } ) Thus if rs is an i...
2007 Mar 29
0
S4 generic surprise
I discovered the following behavior when source'ing the same file repeatedly as I edited it. My generic stopped acting like a generic. I can't tell from the docs what, if any, behavior is expected in this case. R 2.4.0 > foo <- function(object) 3 > isGeneric("foo") [1] FALSE > setMethod("foo", "matrix", function(object) 4) Creating a new generic function for "foo" in ".GlobalEnv" [1] "foo" > foo(0) [1] 3 > foo(matrix(0)) [1] 4 > isGeneric("foo") [1] TRUE # The next step i...
2023 Mar 08
0
Default Generic function for: args(name, default = TRUE)
Dear Gregg, Thank you for the fast response. I believe though that isGeneric works only for S4-functions: isGeneric("plot") # FALSE I still try to get it to work. Sincerely, Leonard On 3/8/2023 9:13 PM, Gregg Powell wrote: > Yes, there is a way to check if a function is generic. You can use the isGeneric function to check if a function is generic. Here...
2003 Jul 26
2
How to make "<-" generic?
Hi, perhaps a little bit unusual: is it possible to use "<- " as generic function with a new signature? The following example doesn't work: > isGeneric("<-") [1] FALSE > setClass("A",representation(x = "numeric")) [1] "A" > setClass("B",representation(x = "numeric")) [1] "B" > myAssign.A <- function(x,value) + { return(x); } > setReplaceMethod("",c(&...
2005 Jun 17
1
(PR#7951) DispatchOrEval missing in do_isfinite and do_isinfinite
...", function(from, ...) standardGeneric("is.finite")) : "is.finite" is a primitive function; methods can be defined, but the generic function is implicit, and can't be changed. If you query about its genericness before you define you own generic, you get: > isGeneric("is.finite") [1] FALSE But after you define you own generic, you get: > setMethod("is.finite", signature(x="TS"), + function(x) { + Data(x) = callNextMethod() + x + }) [1] "is.finite" > isGeneric("...
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 assum...
2009 Aug 17
2
S4 Generics and NAMESPACE : justified warning ?
...ce.R (working copy) @@ -797,8 +797,12 @@ } } for (n in impnames) - if (exists(n, envir = impenv, inherits = FALSE)) - warning(msg, " ", n) + if (exists(n, envir = impenv, inherits = FALSE)) { + if (.isMethodsDispatchOn() && methods:::isGeneric(n, ns)) { + if (methods:::isGeneric(n, impenv)) + warning("replacing previous generic import: ", n) + } else warning(msg, " ", n) + } importIntoEnv(impenv, impnames, ns, impvars) if (register) { addImports(se...
2015 Jan 28
2
[Q] Get formal arguments of my implemented S4 method
......) } Desire to be able to access formals() for the .local() function definition, not the generic one. Have seen information desired available via "defined" slot of returned 'MethodDefinition' object, but not using the code below. ==================== library(methods) if (!isGeneric("normalize")) { ## Other packages also define this generic... setGeneric("normalize", function(object, ...) standardGeneric("normalize")) } setClassUnion("MatrixLike", c("matrix", "data.frame")) .do_normalize <-...
2005 Oct 19
2
Error in opening .RData containing a genefilter object
...d 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. Error in .initContents() : couldn't find function "isGeneric" Error: .onLoad failed in 'loadNamespace' for 'Biobase' Fatal error: unable to restore saved data in .RData [gaia:admin]$ ------- I am working under OS X 10.3.9. David
2012 Apr 12
1
R-2.15.0 and Exporting Methods Converted To S4 Generic
...es 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 (!isGeneric("image")) { setGeneric("image", function(x, ...) standardGeneric("image")) } We have done the same for many S3 generics, converting them to S4 and adding specific method-combinations as such... ## From various other R files... setMethod("image...
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 ?...
2006 May 22
2
confused by inheritance...
Hi r-devels, I am stuck in some S4 inheritance problem: setClass("A",representation(a="numeric")) setClass("A1",representation(b="numeric"),contains="A") setClass("A2",representation(c="numeric"),contains="A1") if(!isGeneric("foo")){ setGeneric("foo", function(x,y,z, ...) standardGeneric("foo")) } setMethod("foo",signature(x = "A", y = "missing", z = "missing"), function(x)x at a ) setMethod("foo",signature(x = "A1", y =...
2004 Jan 08
3
S3, S4, namespace
...red S4 generic in a package, and the method being exported. 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&quo...
2024 Mar 12
1
Spurious warning in as.data.frame.factor()
Hi, The acrobatics that as.data.frame.factor() is going thru in order to recognize a direct call don't play nice if as.data.frame() is an S4 generic: ??? df <- as.data.frame(factor(11:12)) ??? suppressPackageStartupMessages(library(BiocGenerics)) ??? isGeneric("as.data.frame") ??? # [1] TRUE ??? df <- as.data.frame(factor(11:12)) ??? # Warning message: ??? # In as.data.frame.factor(factor(11:12)) : ??? # ? Direct call of 'as.data.frame.factor()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' i...
2007 Jan 31
2
Problems with definitions of S4-generics
..., def=function(object) {standardGeneric("foofunc")}) setGeneric("barfunc", def=function(object) {standardGeneric("barfunc")}) #### Okay, let's start. #### Fist the correct part ## Do some tests to see if the generic is present, ## and have a look at some details isGeneric("foofunc") # [1] TRUE findFunction("foofunc") # [[1]] # <environment: R_GlobalEnv> foofunc # nonstandardGenericFunction for "foofunc" defined from package ".GlobalEnv" # # function (object) # { # standardGeneric("foofunc") # } # <e...
2010 Jan 11
1
Problem with S4 generic function print
...ion to return from, jumping to top level appears after typing 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
2024 Mar 13
1
Spurious warning in as.data.frame.factor()
...gt; The acrobatics that as.data.frame.factor() is going thru in order to > recognize a direct call don't play nice if as.data.frame() is an S4 > generic: > > ??? df <- as.data.frame(factor(11:12)) > > ??? suppressPackageStartupMessages(library(BiocGenerics)) > ??? isGeneric("as.data.frame") > ??? # [1] TRUE > > ??? df <- as.data.frame(factor(11:12)) > ??? # Warning message: > ??? # In as.data.frame.factor(factor(11:12)) : > ??? # ? Direct call of 'as.data.frame.factor()' is deprecated. How about something like the followin...