Skip to content
Back to formatted view

Raw Message

Message-ID: <x2bth43d43.fsf@blueberry.kubism.ku.dk>
Date: 1999-04-04T10:15:56Z
From: Peter Dalgaard
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"

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._