Re: [R] Large matrix into a vector

2007-03-29 Thread Marc Schwartz
On Thu, 2007-03-29 at 02:12 -0700, A Ezhil wrote: > Hi All, > > Thank you very much for all your suggestions. It's a > great learning for me. All the three suggested > solutions seem working. I don't know what 'side > effects' that you were talking about. As Peter noted, the phrase 'side effect'

Re: [R] Large matrix into a vector

2007-03-29 Thread A Ezhil
Hi All, Thank you very much for all your suggestions. It's a great learning for me. All the three suggested solutions seem working. I don't know what 'side effects' that you were talking about. To summarize the responses: > s <- read.table("sample.txt", sep="\t") > s1 <- as.matrix(s) > s1 V1

Re: [R] Large matrix into a vector

2007-03-28 Thread Peter Dalgaard
Marc Schwartz <[EMAIL PROTECTED]> writes: > On Wed, 2007-03-28 at 19:55 -0200, Alberto Monteiro wrote: >> Prof Brian Ripley wrote: >> > >> > We have already seen three solutions. >> > >> > I don't like to see the use of c() for its side effects. In this >> > case Marc's as.vector seems to me to

Re: [R] Large matrix into a vector

2007-03-28 Thread Alberto Monteiro
Prof Brian Ripley wrote: > > We have already seen three solutions. > > I don't like to see the use of c() for its side effects. In this > case Marc's as.vector seems to me to be self-explanatory, and that > is a virtue in programming that is too often undervalued. > I agree; but for our enligh

Re: [R] Large matrix into a vector

2007-03-28 Thread Marc Schwartz
On Wed, 2007-03-28 at 19:55 -0200, Alberto Monteiro wrote: > Prof Brian Ripley wrote: > > > > We have already seen three solutions. > > > > I don't like to see the use of c() for its side effects. In this > > case Marc's as.vector seems to me to be self-explanatory, and that > > is a virtue in

Re: [R] Large matrix into a vector

2007-03-28 Thread John Kane
Is this something like what you want? ab <- rep(1,4) bb <- rep(2,4) cc <- rep(3,4) mydata <- data.frame(ab,bb,cc) unlist(mydata) unlist(data.frame(t(mydata))) --- A Ezhil <[EMAIL PROTECTED]> wrote: > Hi, > > I have a matrix HR(9x27). I would like to make a > single vector with elements: t(HR

Re: [R] Large matrix into a vector

2007-03-28 Thread Prof Brian Ripley
We have already seen three solutions. I don't like to see the use of c() for its side effects. In this case Marc's as.vector seems to me to be self-explanatory, and that is a virtue in programming that is too often undervalued. On Wed, 28 Mar 2007, Marc Schwartz wrote: > On Wed, 2007-03-28 at

Re: [R] Large matrix into a vector

2007-03-28 Thread Alberto Monteiro
A Ezhil wrote: > > I have a matrix HR(9x27). I would like to make a > single vector with elements: t(HR[,1]) followed by > t(HR[,2]) and then t(HR[,3] ... etc. Is there any neat > way of converting this matrix into a vector rather > doing something like c(t(HR[,1]), t(HR[,2]), t(HR[,3]) > ..)? >

Re: [R] Large matrix into a vector

2007-03-28 Thread Marc Schwartz
On Wed, 2007-03-28 at 10:27 -0700, A Ezhil wrote: > Hi, > > I have a matrix HR(9x27). I would like to make a > single vector with elements: t(HR[,1]) followed by > t(HR[,2]) and then t(HR[,3] ... etc. Is there any neat > way of converting this matrix into a vector rather > doing something like c(t

Re: [R] Large matrix into a vector

2007-03-28 Thread Gabor Csardi
A matrix is just a vector with a dim attribute, so if you remove the dim attribute it'll be a vector. The elements of a matrix are stored columnwise so you'll get just what you want, if i get your question right. > g <- matrix(1:6, nc=2, nr=3) > g [,1] [,2] [1,]14 [2,]25 [3,

Re: [R] Large matrix into a vector

2007-03-28 Thread Ravi Varadhan
: Wednesday, March 28, 2007 1:28 PM To: r-help@stat.math.ethz.ch Subject: [R] Large matrix into a vector Hi, I have a matrix HR(9x27). I would like to make a single vector with elements: t(HR[,1]) followed by t(HR[,2]) and then t(HR[,3] ... etc. Is there any neat way of converting this matrix into

[R] Large matrix into a vector

2007-03-28 Thread A Ezhil
Hi, I have a matrix HR(9x27). I would like to make a single vector with elements: t(HR[,1]) followed by t(HR[,2]) and then t(HR[,3] ... etc. Is there any neat way of converting this matrix into a vector rather doing something like c(t(HR[,1]), t(HR[,2]), t(HR[,3]) ..)? Thanks in Advance. Kind reg