From tobias.verbeke at gmail.com  Fri Dec 14 19:26:17 2007
From: tobias.verbeke at gmail.com (Tobias Verbeke)
Date: Fri, 14 Dec 2007 19:26:17 +0100
Subject: [Rd] segfault isoreg with NAs
Message-ID: <4762CAC9.4000506@telenet.be>

Dear list,

As can be seen below, adding a NA to the y values
in a call to isoreg results in a segfault.

ir4 <- isoreg(1:10, y4 <- c(5, 9, 1:2, 5:8, NA, 8))

Adding missing values to the x values, on the contrary,
gives an error, but maybe the error message could be
tailored to this particular situation.

y <- c(5, 9, 1:2, 5:8, 3, 8)
x <- c(1:9, NA)
isoreg(x, y)
## error message: Error in if (!isOrd) { : missing value where 
TRUE/FALSE needed

Please find below a (temporary) patch (against Revision 43692)
for both the R source and the help file.

Kind regards,
Tobias

### patch isoreg.R ###

--- isoreg.R	2007-12-14 19:07:47.000000000 +0100
+++ isoreg2.R	2007-12-14 19:11:20.000000000 +0100
@@ -18,6 +18,9 @@
  ##
  isoreg <- function(x, y=NULL)
  {
+    if (any(is.na(x))) stop("x may not contain NA values")
+    if (any(is.na(y))) stop("y may not contain NA values")
+
      xy <- xy.coords(x,y)
      x <- xy$x
      isOrd <- (!is.null(xy$xlab) && xy$xlab == "Index") || !is.unsorted(x)

### patch isoreg.Rd ###

--- isoreg.Rd	2007-12-14 19:08:12.000000000 +0100
+++ isoreg2.Rd	2007-12-14 19:15:00.000000000 +0100
@@ -20,6 +20,7 @@
    \item{x, y}{%in \code{isoreg},
      coordinate vectors of the regression points.  Alternatively a single
      plotting structure can be specified: see \code{\link{xy.coords}}.
+    The coordinate vectors may not contain missing values.
    }
  }
  \details{


### sessionInfo() information segfault ###

> sessionInfo()
R version 2.6.0 (2007-10-03)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_US.ISO-8859-15;LC_NUMERIC=C;LC_TIME=en_US.ISO-8859-15;LC_COLLATE=en_US.ISO-8859-15;LC_MONETARY=en_US.ISO-8859-15\
;LC_MESSAGES=en_US.ISO-8859-15;LC_PAPER=en_US.ISO-8859-15;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.ISO-885\
9-15;LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
> ir4 <- isoreg(1:10, y4 <- c(5, 9, 1:2, 5:8, NA, 8))

  *** caught segfault ***
address 0x24, cause 'memory not mapped'

Process R segmentation fault (core dumped) at Fri Dec 14 17:48:22 2007



[Rd] segfault isoreg with NAs
Tobias Verbeke