Re: [R] Help with applying a function to all possible 2x2 submatrices

2012-10-23 Thread Michael Friendly
On 10/22/2012 1:10 PM, CMB123 wrote: Hi all, I'm working with a large data set (on the order of 300X300) and trying to apply a function which compares the elements of all possible 2x2 submatrices. There are rc(r-1)(c-1) such submatrices, so obviously the naive method of looping through the rows

Re: [R] Help with applying a function to all possible 2x2 submatrices

2012-10-22 Thread Bert Gunter
Inline. On Mon, Oct 22, 2012 at 1:10 PM, CMB123 wrote: > I apologize if the term "submatrix" was confusing - I am basically 2 rows and > 2 columns from a r x c matrix to construct 2x2 matricies. Thus, the > choose(r,2) * choose(c,2) possible combinations. > > For each matrix [(a,b), (c,d)], What

Re: [R] Help with applying a function to all possible 2x2 submatrices

2012-10-22 Thread CMB123
I apologize if the term "submatrix" was confusing - I am basically 2 rows and 2 columns from a r x c matrix to construct 2x2 matricies. Thus, the choose(r,2) * choose(c,2) possible combinations. For each matrix [(a,b), (c,d)], I am testing a > b, b > d, d > c, and c > a. For the sake of simplicity

Re: [R] Help with applying a function to all possible 2x2 submatrices

2012-10-22 Thread Rui Barradas
Hello, If your matrix is in the order of 300x300, the problem of extracting all possible submatrices and applying a function will allways be a large one, but the use of ?combn may reduce it a bit if the order of rows/columns in the submatrices doesn't matter. It can reduce it from 300^4 = 8.1

Re: [R] Help with applying a function to all possible 2x2 submatrices

2012-10-22 Thread Sarah Goslee
300x300 isn't terribly large; looping should work just fine. But I'm confused about a 2x2 submatrix: I would have thought that a submatrix would be adjacent elements, like x[1:2, 1:2] or x[13:14, 296:297] but your loop compares all possible sets of four elements, so the matrix position doesn't matt

[R] Help with applying a function to all possible 2x2 submatrices

2012-10-22 Thread CMB123
Hi all, I'm working with a large data set (on the order of 300X300) and trying to apply a function which compares the elements of all possible 2x2 submatrices. There are rc(r-1)(c-1) such submatrices, so obviously the naive method of looping through the rows and columns is computationally unfeasib