Just wondering if others have worked with this, and if I am missing
something totally obvious to make this simpler, apologies for my ignorance -


 

OK - it is my understanding that when you reshape a vector (nx1) into a
matrix in R, it reads the matrix by columns, correct?  I discovered that if
you read a vector into GRID, it will read the matrix by rows.  Therefore, it
seems that if you want to take a column vector in R and reshape it to a
matrix in R, you should take the transpose of that column vector before
forming it to a matrix.  Correct?

 

SO - let's say for example I generated a random uniform column vector 16x1
which I was assuming to represent a 4x4 grid, and then I created a 4x4
neighborhood for that grid, then a matrix from that neighborhood (wrk16),
and calculated a spatial moving average:

 

grid1 -> 0.3 * wrk16 %*% grid + grid

 

The result is again a 16x1 column vector - now let's say I want to output
this and read it into GRID - should I reshape it into a 4x4 matrix of the
transpose of the grid1 column vector?

 

That's the best I can figure out.  Seems logical.  BUT, I opened up a grid
whose values I knew, and the southwest corner of the source data was the
northwest corner of the resulting grid.  If I don't do a transpose, the data
are definitely not correct.

 

Thank you,

Darla Munroe


	[[alternative HTML version deleted]]


