Hi everyone, I have a two column (x,y) database with say 20 million rows. I want to check the points that are inside of a hull created with the package alphahull. The function that does this is call �inahull�, and it runs well when I use it for one point at a time. But when I try to optimize the function using �apply�, it gives me the wrong results. I wonder what I am doing wrong? Below is the code: I also wonder if "inahull", could be used in data.table?
library (alphahull) DT<-data.frame(x=c(0.25,0.75,0.75,0.25),y=c(0.25,0.25,0.75,0.75)) #creates hull HULL<-ahull(DT, alpha=0.5) #generate two points as test TEST<-data.frame(x=c(0.25,0.5),y=c(0.5,0.5)) TEST<-data.matrix(TEST) #check individual points InPoint1<-inahull(HULL, c(TEST[1,1],TEST[1,2])) InPoint2<-inahull(HULL, c(TEST[2,1],TEST[2,2])) > InPoint1 [1] FALSE > InPoint2 [1] TRUE #repead check using apply in2D=apply(TEST, 1,function(x, y) inahull(HULL, p = TEST)) > in2D [1] FALSE FALSE [[alternative HTML version deleted]]
______________________________________________ R-help@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.