Re: [R] naming rows/columns in 'array of matrices'

2015-02-02 Thread S Ellison
> > I'd also be interested in why the 'direct, brute force' approach > > (above) doesn't work, Your example was a 3-dimensional array, so > rownames(P) <- colnames(P) <- c(live', 'dead') would have worked; rownames() and colnames() work on dimnames[1] and dimnames[2]. But rownames(P[,,1]) cou

Re: [R] naming rows/columns in 'array of matrices'

2015-02-02 Thread Adams, Jean
In your example, P is a three dimensional array. You can assign names to the three dimensions using the dimnames() function. For example, this command assigns names to the first two dimensions, but leaves the third dimension without names. dimnames(P) <- list(c("live", "dead"), c("live", "dead")

Re: [R] naming rows/columns in 'array of matrices' | solved

2015-01-31 Thread David L Carlson
31, 2015 2:19 AM To: Evan Cooch Cc: r-help@r-project.org Subject: Re: [R] naming rows/columns in 'array of matrices' | solved > On 30 Jan 2015, at 20:34 , Evan Cooch wrote: > > The (obvious, after the fact) solution at the bottom. D'oh... > [snip] > Forgot I was de

Re: [R] naming rows/columns in 'array of matrices' | solved

2015-01-31 Thread peter dalgaard
> On 30 Jan 2015, at 20:34 , Evan Cooch wrote: > > The (obvious, after the fact) solution at the bottom. D'oh... > [snip] > Forgot I was dealing with a multi-dimensional array, not a list. So, > following works fine. I'm sure there are better approaches (where 'better' is > either 'cooler', o

Re: [R] naming rows/columns in 'array of matrices' | solved

2015-01-30 Thread Evan Cooch
The (obvious, after the fact) solution at the bottom. D'oh... On 1/30/2015 2:07 PM, Evan Cooch wrote: Suppose I have the following situation: I have an array of 2 matrices, where each matrix is (2x2): P <- array(0, c(2,2,2)) P[,,1] <- matrix(c(1,2,3,4),2,2,byrow=T); P[,,2] <- matrix(c(5,6,7,8

[R] naming rows/columns in 'array of matrices'

2015-01-30 Thread Evan Cooch
Suppose I have the following situation: I have an array of 2 matrices, where each matrix is (2x2): P <- array(0, c(2,2,2)) P[,,1] <- matrix(c(1,2,3,4),2,2,byrow=T); P[,,2] <- matrix(c(5,6,7,8),2,2,byrow=T); I want to label rows and columns of each matrix in the array, such that P would look l