Re: [R] Faster Solution for a simple code?

2009-04-15 Thread Chris82
Thanks! That's a really fast soltution. Now the R process takes a few seconds instead of a couple of hours with my loop. greets. jholtman wrote: try this: x V1 V2 V3 1 500 320 0 2 510 310 0 3 520 310 0 4 520 320 0 y V1

Re: [R] Faster Solution for a simple code?

2009-04-14 Thread Petr PIKAL
Hi this one could be slightly quicker but i am not completely sure because it gives me different results from yours set.seed(111) x-x1-x2- data.frame(a=sample(1:50, 1, replace=T), b=sample(100:500, 1, replace=T)) y- data.frame(a=sample(1:50, 1, replace=T), b=sample(100:500, 1,

[R] Faster Solution for a simple code?

2009-04-13 Thread Chris82
Hi R-users, I create a simple code to check out how often the same numbers in y occur in x. For example 500 32 occurs two times. But the code with the loop is extremly slow. x have 6100 lines and y sometimes more than 5 lines. Is there any alternative code to create with R?

Re: [R] Faster Solution for a simple code?

2009-04-13 Thread jim holtman
try this: x V1 V2 V3 1 500 320 0 2 510 310 0 3 520 310 0 4 520 320 0 y V1 V2 V3 1 500 320 1 2 500 320 1 3 520 310 1 4 520 300 1 z - merge(x, y, by=c(V1, V2), all.x=TRUE) t(sapply(split(z, z[,1:2],