tabulate causes segmentation fault (PR#156)
Bill Venables
wvenable@arcola.stats.adelaide.edu.au
Sun, 4 Apr 1999 15:41:49 +0930 (CST)
OK, I have a few noodles around my ears...
The fix I gave for tabulate can cause problems with factors (and
breaks truehist in the MASS library!). Here is a further
refinement, which is now getting a little messy, I do admit, but
I'm pretty sure this covers it. (At least truehist works...)
--(begin tabulate.R)--
tabulate <- function (bin, nbins = max(bin)) {
if (!is.numeric(bin) && !is.factor(bin))
stop("tabulate: bin must be numeric or a factor")
nbins <- max(0, nbins)
if (!missing(nbins)) {
if (is.factor(bin))
bin <- unclass(bin)
if (!all(OK <- (bin <= nbins)))
bin <- bin[OK]
}
n <- length(bin)
storage.mode(bin) <- "integer"
.C("tabulate", bin, n, ans = integer(nbins))$ans
}
--(end tabulate.R)--
Bill Venables.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._