From p.dalgaard@biostat.ku.dk  Sun Apr  4 11:15:56 1999
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 04 Apr 1999 12:15:56 +0200
Subject: tabulate causes segmentation fault (PR#156)
In-Reply-To: ripley@stats.ox.ac.uk's message of "Sun, 4 Apr 1999 09:04:17 +0200"
References: <199904040704.JAA31993@blueberry.kubism.ku.dk>
Message-ID: <x2bth43d43.fsf@blueberry.kubism.ku.dk>

ripley@stats.ox.ac.uk writes:

> The code is now much cleaner (I think):
> 
> tabulate <- function(bin, nbins = max(1,bin))
> {
>     if(!is.numeric(bin) && !is.factor(bin))
> 	stop("tabulate: bin must be numeric or a factor")
>     .C("tabulate",
>        as.integer(bin),
>        as.integer(length(bin)),
>        as.integer(nbins),
>        ans = integer(nbins))$ans
> }

.. except that it relies on the following phenomenon:
> max(factor(0:3))
Error: "max" not meaningful for factors
> max(1,factor(0:3))
[1] 4

BTW: Why are we testing for x[i] != R_NaInt in tabulate.c, when 

> tabulate(c(1:3,NA),3)
Error: NAs in foreign function call (arg 1)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


tabulate causes segmentation fault (PR#156)
Peter Dalgaard BSA