[Rd] hist.default for long vectors

Peter Langfelder peter@|@ng|e|der @end|ng |rom gm@||@com
Fri May 13 04:08:34 CEST 2022


Hi all,

this may have been noticed/discussed before but my search came up
empty, so here it is: hist.default throws a (somewhat cryptic) error
when trying to call it on a long vector. The error is

invalid length(x)

and is thrown because lines 4 and 5 or so are

n <- length(x <- x[is.finite(x)])
n <- as.integer(n)

Would adapting hist.default for long vectors be as simple as removing
the as.integer line, or is there other code that depends on n being
representable as a 4-byte integer? I see a 'call' to C_BinCount which
I briefly skimmed and it seems to be ready for long vectors (uses
R_xlen_t for indexing variables). Anything else I am missing?

While we're at it, anyone aware of a hist alternative that can handle
long vectors?

Thanks,

Peter



More information about the R-devel mailing list