[R] Concave hull

David Winsemius dwinsemius at comcast.net
Thu Nov 26 01:51:56 CET 2009


Drats; Forgot the plot:

  xx <- runif(100, 0, 1)
xx <- runif(100, -1, 1)
yy <- abs(xx)+rnorm(100,0,.2); plot(xx,yy, xlim=c( min(xx)-sd(xx),  
max(xx)+sd(xx)), ylim =c( min(yy)-sd(yy), max(yy)+sd(yy)))

dens2 <- kde2d(xx, yy, lims=c(min(xx)-sd(xx), max(xx)+sd(xx), min(yy)- 
sd(yy), max(yy)+sd(yy) )  )
contour(dens2, add=TRUE)
> #  You can pick a single contour if you like:
>
contour(dens2, level=0.05, col="red", add=TRUE)
contour(dens2, level=0.10, col="blue", add=TRUE)



On Nov 25, 2009, at 7:46 PM, David Winsemius wrote:

> This is not a true convave hull, but a 2D density is something  
> similar and perhaps more "statistical":
>
> library(MASS)
> xx <- runif(100, 0, 1)
> xx <- runif(100, -1, 1)
> yy <- abs(xx)+rnorm(100,0,.2)
> dens2 <- kde2d(xx, yy, lims=c(min(xx)-sd(xx), max(xx)+sd(xx),  
> min(yy)-sd(yy), max(yy)+sd(yy) )  )
> contour(dens2, add=TRUE)
>
> #  You can pick a single contour if you like:
>
> contour(dens2, level=0.05, col="red", add=TRUE)
> contour(dens2, level=0.10, col="blue", add=TRUE)
>
>
> Happy Valentine's
> -- 
> David
>
> On Nov 25, 2009, at 11:37 AM, Corrado wrote:
>
>> Dear friends,
>>
>> Do you know how to calculate the CONCAVE hull of a set of points (2-
>> dimensional or n-dimensional)? is that possible in R? (With a  
>> "smoothing"
>> parameter of course).
>>
>> Best,
>> -- 
>> Corrado Topi
>>
>> Global Climate Change & Biodiversity Indicators
>> Area 18,Department of Biology
>> University of York, York, YO10 5YW, UK
>> Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list