[R] own function: computing time

tonja.krueger at web.de tonja.krueger at web.de
Wed Oct 10 12:15:55 CEST 2012


Hi all,

I wrote a function that actually does what I want it to do, but it tends to be very slow for large amount of data. On my computer it takes 5.37 seconds for 16000 data points and 21.95 seconds for 32000 data points. As my real data consists of 18000000 data points it would take ages to use the function as it is now. 
Could someone help me to speed up the calculation?

Thank you, Tonja

system.time({
x <- runif(32000)
y <- runif(32000)

xy <- cbind(x,y) 

outer <- function(z){
!any(x > z[1] & y > z[2])}
j <- apply(xy,1, outer)

plot(x,y)
points(x[j],y[j],col="green")

})



More information about the R-help mailing list