[R] Reducing execution time

Bert Gunter bgunter.4567 at gmail.com
Wed Jul 27 15:30:19 CEST 2016


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" <srivibish at gmail.com> wrote:

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) {
  sum(sapply(myList, function(j) {
    sum(!is.na(match(c(myCombos[i,]), j)))})==3)})

The above code takes very long time to execute and is there any other
effecting method which will reduce the time.
--

Regards,
Srivathsan.K

        [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

	[[alternative HTML version deleted]]



More information about the R-help mailing list