Re: [R] Problem at subsetting matrix by using dimnames

2009-09-21 Thread Agustin Lobo
Thanks a lot. Based on your suggestions, would the following diag(mitest[c("a", "b", "c"), c("b", "c", "b")]) work in general? (it does for my example). If so, I would prefer this form as I understand it better. Agus Henrique Dallazuanna wrote: Try this: mapply(function(x, y)mitest[x, y], c

Re: [R] Problem at subsetting matrix by using dimnames

2009-09-02 Thread Henrique Dallazuanna
Try this: mapply(function(x, y)mitest[x, y], c("a", "b", "c"), c("b", "c", "b")) or diag(`[`(mitest, i = c("a", "b", "c"), j = c("b", "c", "b"))) On Wed, Sep 2, 2009 at 6:57 AM, Agustin Lobo wrote: > Given: > > > mitest <- matrix(1:16,ncol=4) > > dimnames(mitest)[[1]] <- c("a","b","c","d")