Re: [R] matrix transpose

2009-02-15 Thread Wacek Kusnierczyk
Rolf Turner wrote: > > On 16/02/2009, at 8:36 AM, Roger wrote: > >> This is supposed to be an easy operation, but R 2.8.1 on Mac OS X >> gives me a >> lot trouble. the t() function simply does not work properly. What I >> mean is >> it works sometimes but does not work at the most of the time, eve

Re: [R] matrix transpose

2009-02-15 Thread Daniel Viar
Here's one way that seems to work: a <- matrix(1:30,5,6) # Create a target for the transpose b <- matrix(1:(nrow(a)*ncol(a)),ncol(a),nrow(a)) # populate b with the transpose of a for (i in 1:ncol(a)) { b[i,1:(nrow(a))] <- a[1:(nrow(a)),i]} # Check: Did it work? all.equal(b,t(a)) I'm sure there's

Re: [R] matrix transpose

2009-02-15 Thread Wacek Kusnierczyk
Roger wrote: > This is supposed to be an easy operation, but R 2.8.1 on Mac OS X gives me a > lot trouble. the t() function simply does not work properly. What I mean is > it works sometimes but does not work at the most of the time, even with the > same matrix. > > this is an example taken from R

Re: [R] matrix transpose

2009-02-15 Thread Rolf Turner
On 16/02/2009, at 8:36 AM, Roger wrote: This is supposed to be an easy operation, but R 2.8.1 on Mac OS X gives me a lot trouble. the t() function simply does not work properly. What I mean is it works sometimes but does not work at the most of the time, even with the same matrix. this

[R] matrix transpose

2009-02-15 Thread Roger
This is supposed to be an easy operation, but R 2.8.1 on Mac OS X gives me a lot trouble. the t() function simply does not work properly. What I mean is it works sometimes but does not work at the most of the time, even with the same matrix. this is an example taken from R help > a <- matrix(1:3