search for: genericforprimit

Displaying 11 results from an estimated 11 matches for "genericforprimit".

2015 Jan 21
2
reducing redundant work in methods package
Doing it like this: genericForPrimitive <- function(f, where = topenv(parent.frame()), mustFind = TRUE) { ans = .BasicFunsList[[f]] ## this element may not exist (yet, during loading), dom't test null if(mustFind && identical(ans, FALSE)) stop(gettextf("methods may not be defined for primiti...
2015 Jan 21
2
reducing redundant work in methods package
Hi all, The function call series genericForPrimitive -> .findBasicFuns -> .findAll happens 4400 times while the GenomicRanges package is loading. Each time .findAll follows a chain of environments to determine that the methods namespace is the only one that holds a variable called .BasicFunsList. This accounts for ~10% of package loading ti...
2004 Jun 26
1
S4 group "Math", "getGroupMembers", "genericForPrimitive"
...ersion 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 'getGeneric'. It seems that this method is not included in the R Version 1.9.1 (also 1.9.0). See the example code of John Chambers at the end of this email. Why not add the method 'getGroupMembers' as proposed by John Chambers to the methods package? (see r...
2015 Jan 22
0
reducing redundant work in methods package
I also just noticed that there is a bug: identical(ans, FALSE) should be is.null(ans). So no error is thrown: > methods:::genericForPrimitive("foo") NULL Will fix. On Wed, Jan 21, 2015 at 3:13 PM, Peter Haverty <haverty.peter at gene.com> wrote: > Doing it like this: > > genericForPrimitive <- function(f, where = topenv(parent.frame()), mustFind > = TRUE) { > > ans = .BasicFunsList[[f]] >...
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 R According to the man page: ?isGeneric?: Is...
2015 Jan 21
0
reducing redundant work in methods package
Note that setMethod() resolves .BasicFunsList in the methods namespace directly when setting a method on a primitive. Somehow there should be consistency between genericForPrimitive() and the check in setMethod(). Also, we can probably step away from the use of elNamed(), given that [[ now uses exact matching. Have you tried patching methods to use .BasicFunsList directly as in setMethod? On Wed, Jan 21, 2015 at 10:41 AM, Peter Haverty <haverty.peter at gene.com>...
2007 Jan 25
1
"rep" missing from methods:::.BasicFunsList
With: R version 2.4.1 Patched (2007-01-22 r40548) "rep" is missing from methods:::.BasicFunsList, causing methods:::genericForPrimitive("rep") to fail, which in turn causes setMethod("rep", ...) to fail. (setGeneric("rep") of course fails as it should, saying that rep is a primitive and methods can be set). Here's the fix: build_main at mambo:/vobs/products/R> gdiff -ub src/library/metho...
2005 Jan 14
1
RE: [R] as.character methods
...in r-devel are clear enough without actively discouraging discussion of classes and methods. It's the nature of the question, not a litmus test for discussing this or that package that is the helpful distinction. .... > if (is.primitive(baseDef)) { > value <- genericForPrimitive(f) > > and it seems John Chambers has defined an S4 generic for as.character > with one arg, "x". Had he not done so it would have been (x, ...). My > guess is that this is because in S the arg list is (x) and he overlooked > that it was not in R, but only he knows....
2009 Jan 25
3
Defining an iterator
Inspired by Rudolf Biczok's query of Fri, Jan 23, 2009 at 1:25 AM, I tried to implement iteration in a generic way using S4. (Though I am admittedly still struggling with learning S4.) > setClass("foo",representation(bar="list")) [1] "foo" > x<-new("foo",bar=list(1,2,3)) Given this, I would not expect for(i in x)... to work, since R has no way
2005 Jan 13
3
as.character methods
Hello, ?as.character says that the as.character function is a generic with usage: as.character(x, ...). So, I want to create an S4 object with an as.character method following the above usage, but I get the below error telling me that ... isn't in the generic for as.character. > setClass("tmp", "numeric") > setMethod("as.character", "tmp",
2005 Jan 13
3
as.character methods
Hello, ?as.character says that the as.character function is a generic with usage: as.character(x, ...). So, I want to create an S4 object with an as.character method following the above usage, but I get the below error telling me that ... isn't in the generic for as.character. > setClass("tmp", "numeric") > setMethod("as.character", "tmp",