similar to: as(1:4, "numeric") versus as.numeric(1:4, "numeric")

Displaying 20 results from an estimated 10000 matches similar to: "as(1:4, "numeric") versus as.numeric(1:4, "numeric")"

2015 Dec 19
2
For integer vectors, `as(x, "numeric")` has no effect.
As I tried to say on Dec. 11, there are two levels of "fix": 1. The fix to the complaint in the OP's subject heading is to conform to the default third argument, strict=TRUE: as(1L, "numeric") == 1.0 This generates some incompatibilities, as for classes that extend "numeric". But still leaves class(1.0) "numeric" and typeof(1.0) "double".
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")
2012 Mar 24
2
RC / methods package
(I think this is being caused by the new methods package in RC.) In the RC (March 24) some of my packages are generating a Note Note: Method with signature "MySQLConnection#integer" chosen for function "coerce", target signature "TSMySQLConnection#integer". "dbObjectId#integer" would also be valid This is coming from a call to dbGetQuery() in package
2009 Jun 02
2
formal argument "envir" matched by multiple actual arguments
Hi list, This looks similar to the problem reported here https://stat.ethz.ch/pipermail/r-devel/2006-April/037199.html by Henrik Bengtsson a long time ago. It is very sporadic and non-reproducible. Henrik, do you remember if your code was using reg.finalizer()? I tend to suspect it but I'm not sure. I've been hunting this bug for months but today, and we the help of other Bioconductor
2011 Dec 07
4
bug in rank(), order(), is.unsorted() on character vector
Hi, This looks OK: > x <- c("_1_", "1_9", "2_9") > rank(x) [1] 1 2 3 But this does not: > xa <- paste(x, "a", sep="") > xa [1] "_1_a" "1_9a" "2_9a" > rank(xa) [1] 2 1 3 Cheers, H. > sessionInfo() R version 2.14.0 (2011-10-31) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1]
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, ...)
2011 Dec 09
3
bug in sum() on integer vector
Hi, x <- c(rep(1800000003L, 10000000), -rep(1200000002L, 15000000)) This is correct: > sum(as.double(x)) [1] 0 This is not: > sum(x) [1] 4996000 Returning NA (with a warning) would also be acceptable for the latter. That would make it consistent with cumsum(x): > cumsum(x)[length(x)] [1] NA Warning message: Integer overflow in 'cumsum'; use
2011 Sep 23
1
broken save(..., compress="xy")
Hi, With current R devel and R 2.13.1: > aa=1:5 > save(aa, file="aa.rda", compress="xy") Error in identical(compress, "gzip") || compress : invalid 'y' type in 'x || y' Thanks! H. > sessionInfo() R version 2.13.1 (2011-07-08) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3]
2019 Mar 22
2
selectMethod() can fail to find methods in situations of multiple dispatch
Hi Michael, Thanks for looking into this. I suspect that truncation of ANY suffixes from method signatures is also the culprit behind the sudden breakage of aliases of the form \alias{foo,numeric-method} when a method without the ANY suffix in its signature gets added to the ecosystem. See my post about this to the Bioc-devel mailing list a couple of months ago:
2019 Mar 14
2
selectMethod() can fail to find methods in situations of multiple dispatch
Here is an example: setGeneric("foo", function(x, y) standardGeneric("foo")) setMethod("foo", c("numeric", "ANY"), function(x, y) cat("I'm the foo#numeric#ANY method\n") ) Dispatch works as expected but selectMethod() fails to find the method: > foo(1, TRUE) I'm the foo#numeric#ANY method >
2019 Mar 22
2
selectMethod() can fail to find methods in situations of multiple dispatch
Fine with me as long as eliminating the inconveniences associated with it can be put on the roadmap. The alias instability and the fact that the user has no way to know if s/he should do ?`foo,numeric-method` or ?`foo,numeric,ANY-method` to find the method has been a long-standing problem. H. On 3/21/19 21:29, Michael Lawrence wrote: If we started over, I'd try to avoid this sort of
2015 Mar 12
2
Requirement for pandoc 1.12.3 in R 3.1.3
Thanks Brian. Indeed, the vignette is in markdown form. When I updated my system to R 3.1.3 I ran update.packages() and this seems to have upset things (including R-studio processing of markdown files). I tried removing rmarkdown and reverting to an older version so that my sessionInfo() is Loading required package: rmarkdown > sessionInfo() R version 3.1.3 (2015-03-09) Platform:
2009 Jul 16
1
Resizing a named vector crashes R with gctorture(TRUE) (PR#13837)
On 15/07/2009 8:08 PM, Herv? Pag?s wrote: > Hi, > > > x <- c(a=10, b=20) > > length(x) <- 1 > > x > a > 10 > > But with gctorture turned on, I get: > > > gctorture(TRUE) > > x <- c(a=10, b=20) > > length(x) <- 1 > > x > a > "a" <---- ??? > > > x <-
2015 Dec 08
2
For integer vectors, `as(x, "numeric")` has no effect.
We do need an explicit method here, I think. The issue is that as() uses methods for the generic function coerce() but cannot use inheritance in the usual way (if it did, you would be immediately back with no change, since "integer" inherits from "numeric"). Copying in the general method for coercing to "numeric" as an explicit method for "integer" gives
2009 Jul 15
1
Protection stack overflow
Hi, > gctorture(TRUE) > setGeneric("foo", function(x, y) standardGeneric("foo")) [1] "foo" > setMethod("foo", c("ANY", "ANY"), + function(x, y) cat("calling foo,ANY,ANY method\n") + ) Error: protect(): protection stack overflow Sorry this is something I already reported one week ago here
2009 Sep 24
1
crash with NAs in subscripted assignment of a raw vector
Hi, > x <- charToRaw("ABCDEFGx") > x[c(1:3, NA, 6)] <- x[8] *** caught segfault *** address 0x8402423f, cause 'memory not mapped' Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Cheers, H. > sessionInfo() R version 2.10.0 Under development
2010 Jun 03
1
named empty list
Hi, I just realized that a named empty list is displayed the same way as an empty list: > list(aa=2:5)[0] list() > list() list() For empty atomic vectors, the print method makes the difference: > c(aa=3L)[0] named integer(0) > integer(0) integer(0) Maybe lists could do that too? Thanks, H. > sessionInfo() R version 2.12.0 Under development (unstable)
2016 Mar 04
2
as.vector in R-devel loaded 3/3/2016
I see as below, where getGeneric and getMethod imply a different signature; the signature is mode="any" for both cases in R version 3.2.3 Patched (2016-01-28 r70038)I don't know how to reproduce Jeff's error, though. > library(Matrix) > as.vector function (x, mode = "any") .Internal(as.vector(x, mode)) <bytecode: 0xe79f88> <environment:
2011 Sep 23
2
cbind() crashes on raw vectors
Hi, cbind() doesn't seem to like raw vectors: > df <- cbind(a=integer(4000), b=raw(4000)) > df *** glibc detected *** /home/hpages/R-2.13.1/bin/exec/R: malloc(): memory corruption: 0x0000000002d73ca0 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x79d7a)[0x7f3592b91d7a] /lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x6e)[0x7f3592b9431e]
2015 Dec 04
2
For integer vectors, `as(x, "numeric")` has no effect.
Here's the surprising behavior: x <- 1L xx <- as(x, "numeric") class(xx) ## [1] "integer" It occurs because the call to `as(x, "numeric")` dispatches the coerce S4 method for the signature `c("integer", "numeric")`, whose body is copied in below. function (from, to = "numeric", strict = TRUE) if (strict) {