Re: [R] Help on improving an algorithm

2016-07-28 Thread li li
Thanks very much Don! You alternative method does make it much faster. However I think I made a mistake in my previous coding. Sorry. Instead of checking whether each row sum is larger than 8, what I wanted is to check whether each column sum is lager than 8. See the code below. So in this case,

Re: [R] Help on improving an algorithm

2016-07-28 Thread MacQueen, Don
This is a good example to illustrate that R is a vectorized language, and programming concepts that would work in fortran, C, or any of many other languages are not always effective in R. The vectorized method below has produced the same value for 'p' in every example I¹ve tried, and is much faste

[R] Help on improving an algorithm

2016-07-27 Thread li li
Hi all, I have four matrix tmp_a, tmp_b, tmp_c and tmp_d whose dimensions are shown as below. I want to take one row from each of these matrices and then put the four selected rows into a matrix. I want to count the number of such matrices for which the vector of row sum is less than or equal to (