similar to: sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31

Displaying 20 results from an estimated 6000 matches similar to: "sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31"

2018 Jan 25
2
sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31
Just following up on this old thread since matrixStats 0.53.0 is now out, which supports this use case: > x <- rep(TRUE, times = 2^31) > y <- sum(x) > y [1] NA Warning message: In sum(x) : integer overflow - use sum(as.numeric(.)) > y <- matrixStats::sum2(x, mode = "double") > y [1] 2147483648 > str(y) num 2.15e+09 No coercion is taking place, so the
2018 Jan 30
2
sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31
Hi Martin, Henrik, Thanks for the follow up. @Martin: I vote for 2) without *any* hesitation :-) (and uniformity could be restored at some point in the future by having prod(), rowSums(), colSums(), and others align with the behavior of length() and sum()) Cheers, H. On 01/27/2018 03:06 AM, Martin Maechler wrote: >>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>
2018 Feb 01
0
sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31
>>>>> Herv? Pag?s <hpages at fredhutch.org> >>>>> on Tue, 30 Jan 2018 13:30:18 -0800 writes: > Hi Martin, Henrik, > Thanks for the follow up. > @Martin: I vote for 2) without *any* hesitation :-) > (and uniformity could be restored at some point in the > future by having prod(), rowSums(), colSums(), and others >
2018 Jan 27
0
sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com> >>>>> on Thu, 25 Jan 2018 09:30:42 -0800 writes: > Just following up on this old thread since matrixStats 0.53.0 is now > out, which supports this use case: >> x <- rep(TRUE, times = 2^31) >> y <- sum(x) >> y > [1] NA > Warning message:
2017 Jun 02
0
sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31
I second this feature request (it's understandable that this and possibly other parts of the code was left behind / forgotten after the introduction of long vector). I think mean() avoids full copies, so in the meanwhile, you can work around this limitation using: countTRUE <- function(x, na.rm = FALSE) { nx <- length(x) if (nx < .Machine$integer.max) return(sum(x, na.rm =
2017 Jun 07
1
sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31
>>>>> Martin Maechler <maechler at stat.math.ethz.ch> >>>>> on Tue, 6 Jun 2017 09:45:44 +0200 writes: >>>>> Herv? Pag?s <hpages at fredhutch.org> >>>>> on Fri, 2 Jun 2017 04:05:15 -0700 writes: >> Hi, I have a long numeric vector 'xx' and I want to use >> sum() to count the number of
2017 Nov 29
2
binary form of is() contradicts its unary form
Hi Mehmet, On 11/29/2017 11:22 AM, Suzen, Mehmet wrote: > Hi Herve, > > I think you are confusing subclasses and classes. There is no > contradiction. `is` documentation > is very clear: > > `With one argument, returns all the super-classes of this object's class.` Yes that's indeed very clear. So if "list" is a super-class of "data.frame" (as
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
2016 Mar 19
2
unary class union of an S3 class
On 03/19/2016 01:22 AM, Michael Lawrence wrote: > > > On Sat, Mar 19, 2016 at 12:10 AM, Herv? Pag?s <hpages at fredhutch.org > <mailto:hpages at fredhutch.org>> wrote: > > On 03/18/2016 03:28 PM, Michael Lawrence wrote: > > > On Fri, Mar 18, 2016 at 2:53 PM, Herv? Pag?s > <hpages at fredhutch.org <mailto:hpages at
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:
2015 Sep 29
3
making object.size() more meaningful on environments?
Hi, Currently object.size() is not very useful on environments as it always returns 56 bytes, no matter how big the environment is: env1 <- new.env() object.size(env1) # 56 bytes env2 <- new.env(hash=TRUE, size=75000000L) object.size(env2) # 56 bytes env3 <- list2env(list(a=runif(25000000), L=LETTERS)) object.size(env3) # 56 bytes This makes it pretty useless on
2018 Jan 30
2
as.list method for by Objects
by() does not always return a list. In Gabe's example, it returns an integer, thus it is coerced to a list. as.list() means that it should be a VECSXP, not necessarily with "list" in the class attribute. Michael On Tue, Jan 30, 2018 at 2:41 PM, Herv? Pag?s <hpages at fredhutch.org> wrote: > Hi Gabe, > > Interestingly the behavior of as.list() on by objects seem to
2020 May 22
2
paste(character(0), collapse="", recycle0=FALSE) should be ""
I agree with Herve, processing collapse happens last so collapse=non-NULL always leads to a single character string being returned, the same as paste(collapse=""). See the altPaste function I posted yesterday. Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, May 22, 2020 at 9:12 AM Herv? Pag?s <hpages at fredhutch.org> wrote: > I think that > >
2016 Nov 15
1
creating a long list puts R in a state where many things stop working
Hi, After I create a long list e.g. with x <- vector(mode="list", length=3e9) many bad things start to happen e.g. some things stop working with a spurious error message: gc() # Error in gc() : # long vectors not supported yet: /home/hpages/src/R-3.3.2/src/main/memory.c:1137 x_lens <- lengths(x) # Error in lengths(x) : # long vectors not supported yet:
2020 Mar 27
1
object.size vs lobstr::obj_size
On 3/27/20 15:19, Hadley Wickham wrote: > > > On Fri, Mar 27, 2020 at 4:01 PM Herv? Pag?s <hpages at fredhutch.org > <mailto:hpages at fredhutch.org>> wrote: > > > > On 3/27/20 12:00, Hadley Wickham wrote: > > > > > > On Fri, Mar 27, 2020 at 10:39 AM Herv? Pag?s > <hpages at fredhutch.org <mailto:hpages at
2017 May 03
2
stopifnot() does not stop at first non-TRUE argument
Not sure why the performance penalty of nonstandard evaluation would be more of a concern here than for something like switch(). If that can't/won't be fixed, what about fixing the man page so it's in sync with the current behavior? Thanks, H. On 05/03/2017 02:26 AM, peter dalgaard wrote: > The first line of stopifnot is > > n <- length(ll <- list(...)) > >
2020 Mar 27
2
object.size vs lobstr::obj_size
On 3/27/20 12:00, Hadley Wickham wrote: > > > On Fri, Mar 27, 2020 at 10:39 AM Herv? Pag?s <hpages at fredhutch.org > <mailto:hpages at fredhutch.org>> wrote: > > Hi Tomas, > > On 3/27/20 07:01, Tomas Kalibera wrote: > > they provide an over-approximation > > They can also provide an "under-approximation" (to say the
2020 May 22
2
paste(character(0), collapse="", recycle0=FALSE) should be ""
Hi Martin et al, On Thu, May 21, 2020 at 9:42 AM Martin Maechler <maechler at stat.math.ethz.ch> wrote: > >>>>> Herv? Pag?s > >>>>> on Fri, 15 May 2020 13:44:28 -0700 writes: > > > There is still the situation where **both** 'sep' and 'collapse' are > > specified: > > >> paste(integer(0),
2017 Nov 29
2
binary form of is() contradicts its unary form
Hi, The unary forms of is() and extends() report that data.frame extends list, oldClass, and vector: > is(data.frame()) [1] "data.frame" "list" "oldClass" "vector" > extends("data.frame") [1] "data.frame" "list" "oldClass" "vector" However, the binary form of is()
2020 May 22
5
paste(character(0), collapse="", recycle0=FALSE) should be ""
Gabe, It's the current behavior of paste() that is a major source of bugs: ## Add "rs" prefix to SNP ids and collapse them in a ## comma-separated string. collapse_snp_ids <- function(snp_ids) paste("rs", snp_ids, sep="", collapse=",") snp_groups <- list( group1=c(55, 22, 200), group2=integer(0), group3=c(99,