Re: [R] Reducing execution time

2016-07-29 Thread sri vathsan
Hi, Thanks for the response. Unfortunately this did not solve my problem and may be the way I represented my data would be the problem. I am not sure that I can give a link for the data which will give a clear representation. If that is not a proper way, I have to follow my original method. Regar

Re: [R] Reducing execution time

2016-07-27 Thread jeremiah rounds
Correction to my code. I created a "doc" variable because I was thinking of doing something faster, but I never did the change. grep needed to work on the original source "dat" to be used for counting. Fixed: combs = structure(list(V1 = c(65L, 77L, 55L, 23L, 34L), V2 = c(23L, 34L, 34L, 77L, 65L

Re: [R] Reducing execution time

2016-07-27 Thread jeremiah rounds
If I understood the request this is the same programming task as counting words in a document and counting character sequences in a string or matching bytes in byte arrays (though you don't want to go down that far) You can do something like what follows. There are also vectorized greps in strin

Re: [R] Reducing execution time

2016-07-27 Thread sri vathsan
Hi, It is not a just 79 triplets. As I said, there are 79 codes. I am making triplets out of that 79 codes and matching the triplets in the list. Please find the dput of the data below. > dput(head(newd,10)) structure(list(uniq_id = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"), hi = c("1

Re: [R] Reducing execution time

2016-07-27 Thread Sarah Goslee
You said you had 79 triplets and 8000 records. When I compared 100 triplets to 1 records it took 86 seconds. So obviously there is something you're not telling us about the format of your data. If you use dput() to provide actual examples, you will get better results than if we on Rhelp have

Re: [R] Reducing execution time

2016-07-27 Thread sri vathsan
Hi, Thanks for the solution. But I am afraid that after running this code still it takes more time. It has been an hour and still it is executing. I understand the delay because each triplet has to compare almost 9000 elements. Regards, Sri On Wed, Jul 27, 2016 at 9:02 PM, Sarah Goslee wrote:

Re: [R] Reducing execution time

2016-07-27 Thread Sarah Goslee
Hi, It's really a good idea to use dput() or some other reproducible way to provide data. I had to guess as to what your data looked like. It appears that order doesn't matter? Given than, here's one approach: combs <- structure(list(V1 = c(65L, 77L, 55L, 23L, 34L), V2 = c(23L, 34L, 34L, 77L, 6

Re: [R] Reducing execution time

2016-07-27 Thread sri vathsan
Hi, Apologizes for the less information. Basically, myCombos is a matrix with 3 variables which is a triplet that is a combination of 79 codes. There are around 3lakh combination as such and it looks like below. V1 V2 V3 65 23 77 77 34 65 55 34 23 23 77 34 34 65 55 Each triplet will compare in

Re: [R] Reducing execution time

2016-07-27 Thread Bert Gunter
Not entirely sure I understand, but match() is already vectorized, so you should be able to lose the supply(). This would speed things up a lot. Please re-read ?match *carefully* . Bert On Jul 27, 2016 6:15 AM, "sri vathsan" wrote: Hi, I created list of 3 combination numbers (mycombos, around

Re: [R] Reducing execution time

2016-07-27 Thread Thierry Onkelinx
A reproducible example makes your problem easier to understand. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the stat

[R] Reducing execution time

2016-07-27 Thread sri vathsan
Hi, I created list of 3 combination numbers (mycombos, around 3 lakh combinations) and counting the occurrence of those combination in another list. This comparision list (mylist) is having around 8000 records.I am using the following code. myCounts <- sapply(1:nrow(myCombos), FUN=function(i) {