Skip to content
Prev 82919 / 398513 Next

selecting matrix cels by two factors

You can subscript any arbitrary array (of any dim) with an appropriately
dimensioned matrix of integer indices. So all you have to do is convert the
dimnames into indices. One simple way to do this is:

X[cbind(match(c("D","E","F","D","E","F"),rownames(X)),
	match(c("A","C","A","B","B","C"),colnames(X)))]

This gives a vector, which you can dimension however you like.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box