Displaying 20 results from an estimated 8000 matches similar to: "isGeneric() can return an error"
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:
---------------------------------------------------
> version
_
platform i686-pc-linux-gnu
arch i686
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
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 primitive function %s
in this version of R",
2009 Feb 25
1
Unexpected side effect of the ":::" operator on the value of isGeneric
Hi,
when running the following on a fresh R,
library("IRanges")
annotation
showMethods("annotation")
Biobase:::annotation
showMethods("annotation")
I get (see the "^^^^^" marked output at the bottom):
> library("IRanges")
Carico il pacchetto richiesto: 'IRanges'
The following object(s) are masked from package:base :
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 time. I'm sure there is some history
to that
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
2024 Mar 13
1
Spurious warning in as.data.frame.factor()
? Tue, 12 Mar 2024 12:33:17 -0700
Herv? Pag?s <hpages.on.github at gmail.com> ?????:
> 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))
> ???
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
2014 May 07
0
Historical NA question (Herv? Pag?s)
"Equivalence" certainly does not mean that literally replacing some text will not change the result.
>From "R language definition", p. 11:
> Except for the syntax, there is no difference between applying an operator and calling a
function. In fact, x + y can equivalently be written ?+?(x, y). Notice that since ?+? is a nonstandard
function name, it needs to be quoted.
2012 Oct 11
1
as.data.frame.matrix() returns an invalid object
Hi,
Two ways to create what should normally be the same data frame:
> df1 <- data.frame(a=character(0), b=character(0))> df1
[1] a b
<0 rows> (or 0-length row.names)
> df2 <- as.data.frame(matrix(character(0), ncol=2,
dimnames=list(NULL, letters[1:2])))
> df2
[1] a b
<0 rows> (or 0-length row.names)
unique() works as expected except that I
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",
2012 Oct 01
1
False positive note about ambiguous dispatch
Hi,
In the situation below the note issued by the dispatch algo doesn't
seem right:
setClass("A", representation(stuff="complex"))
setAs("ANY", "A", function(from) new("A", stuff=as.complex(from)))
> as(6, "A")
An object of class "A"
Slot "stuff":
[1] 6+0i
> as(6L, "A")
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 <-
2014 Mar 27
3
[Bioc-devel] Conflicting definitions for function redefined as S4 generics
On 03/27/2014 02:13 AM, Ulrich Bodenhofer wrote:
> I fully agree, Michael, that this would be a great thing to have! I have
> often wondered why R and the standard packages are still sticking so
> much to the old-style S3 flavor though S4 is part of standard R. I
> acknowledge that backward compatibility is important, but, as far as I
> got it, redefining a function or S3 generic as
2005 Jun 17
1
(PR#7951) DispatchOrEval missing in do_isfinite and do_isinfinite
Hi,
OK, if you try to explicitly make them generic, you are told that they
are implicitly already generic:
> setGeneric("is.finite", function(from, ...) standardGeneric("is.finite"))
Error in setGeneric("is.finite", function(from, ...)
standardGeneric("is.finite")) :
"is.finite" is a primitive function; methods can be defined, but
the
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
2017 Nov 29
2
binary form of is() contradicts its unary form
Yes, data.frame is not an S4 class but is(data.frame())
finds its super-classes anyway and without the need to wrap
it in asS4(). And "list' is one of the super-classes. Then
is(data.frame(), "list") contradicts this.
I'm not asking for a workaround. I already have one with
'class2 %in% is(object)' as reported in my original post.
'is(asS4(object), class2)'
2013 Apr 23
1
about the 'length' arg of vector()
Hi,
In the man page for vector():
length: A non-negative integer specifying the desired length. Double
values will be coerced to integer: supplying an argument of
length other than one is an error.
Since long vectors are supported, it doesn't seem to be true anymore
that "double values will be coerced to integer":
> bigraw <-
2013 Dec 13
1
substring() and propagation of names
Hi,
In R < 3.0.0, we used to get:
> substring(c(A="abcdefghij", B="123456789"), 2, 6:2)
A B A B A
"bcdef" "2345" "bcd" "23" "b"
But in R >= 3.0.0, we get:
> substring(c(A="abcdefghij", B="123456789"), 2, 6:2)
[1] "bcdef"
2015 Sep 29
1
making object.size() more meaningful on environments?
Hi Gabe,
On 09/29/2015 02:51 PM, Gabriel Becker wrote:
> Herve,
>
> The problem then would be that for A a refClass whose fields take up N
> bytes (in the sense that you mean), if we do
>
> B <- A
>
> A and B would look like the BOTH take up N bytes, for a total of 2N,
> whereas AFAIK R would only be using ~ N + 2*56 bytes, right?
Yes, but that's still a *much*