Bug 15777 - chull() fails if both x and y contain NAs at the first or last index
Summary: chull() fails if both x and y contain NAs at the first or last index
Status: CLOSED INVALID
Alias: None
Product: R
Classification: Unclassified
Component: Analyses (show other bugs)
Version: R 3.0.2
Hardware: x86_64/x64/amd64 (64-bit) Linux
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-04-25 07:23 UTC by Fabian S
Modified: 2014-05-14 15:38 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian S 2014-04-25 07:23:48 UTC
If both x and y contain NAs at the first or last index, `chull()` always returns 

c(1, length(x)) 

as the result:

> chull(1:10, c(1:5, 5:1))
[1] 10  1  5  6
> chull(c(1:10, NA), c(1:5, 5:1, NA))
[1]  1 11
> chull(c(NA, 1:10), c(NA, 1:5, 5:1))
[1]  1 11
Comment 1 Fabian S 2014-04-25 07:54:19 UTC
I filed this too quickly: `chull()` fails generally if there are NAs in x and y at the same locations, not just at the first or last:

> set.seed(121222)
> 
> nas <- sample(2:99, 20)
> x <- runif(100)
> y <- runif(100)
> x[nas] <- NA
> y[nas] <- NA
> 
> length(chull(x,y))
[1] 16
> length(chull(x[-nas], y[-nas]))
[1] 10

Obviously returns of these two calls must contain different indices, but should 
represent identical polygns and therefore have the same length...
Comment 2 Brian Ripley 2014-05-14 15:38:41 UTC
As nothing said NA values would be omitted these were not the same polygons, and NAs were treated as actual values.

Non-finite values (include NA) now give an explicit error.