Re: [R] Quicker way of combining vectors into a data.frame

2006-12-01 Thread Gavin Simpson
[ Resending to the list as I fell foul of the too many recipients rule ] On Thu, 2006-11-30 at 11:34 -0600, Marc Schwartz wrote: Thanks to Marc, Prof. Ripley, Sebastian and Sebastian (Luque - offline) for your comments and suggestions. I noticed that two of the vectors were named and so I

Re: [R] Quicker way of combining vectors into a data.frame

2006-12-01 Thread Peter Dalgaard
Gavin Simpson wrote: [ Resending to the list as I fell foul of the too many recipients rule ] On Thu, 2006-11-30 at 11:34 -0600, Marc Schwartz wrote: Thanks to Marc, Prof. Ripley, Sebastian and Sebastian (Luque - offline) for your comments and suggestions. I noticed that two of the vectors

Re: [R] Quicker way of combining vectors into a data.frame

2006-12-01 Thread Gavin Simpson
On Fri, 2006-12-01 at 12:13 +0100, Peter Dalgaard wrote: Gavin Simpson wrote: snip / I just don't understand what is going on with data.frame. I think there is something about the data you're not telling us... Yes, that I was doing something very, very silly that I thought would work

Re: [R] Quicker way of combining vectors into a data.frame

2006-12-01 Thread Marc Schwartz
On Thu, 2006-11-30 at 19:26 +, Gavin Simpson wrote: On Thu, 2006-11-30 at 11:34 -0600, Marc Schwartz wrote: Thanks to Marc, Prof. Ripley, Sebastian and Sebastian (Luque - offline) for your comments and suggestions. I noticed that two of the vectors were named and so I removed the names

[R] Quicker way of combining vectors into a data.frame

2006-11-30 Thread Gavin Simpson
Hi, In a function, I compute 10 (un-named) vectors of reasonable length (4471 in the particular example I have to hand) that I want to combine into a data frame object, that the function will return. This is very slow, so *I'm* doing something wrong if I want it to be quick and efficient, though

Re: [R] Quicker way of combining vectors into a data.frame

2006-11-30 Thread Marc Schwartz
On Thu, 2006-11-30 at 17:00 +, Gavin Simpson wrote: Hi, In a function, I compute 10 (un-named) vectors of reasonable length (4471 in the particular example I have to hand) that I want to combine into a data frame object, that the function will return. This is very slow, so *I'm* doing

Re: [R] Quicker way of combining vectors into a data.frame

2006-11-30 Thread Prof Brian Ripley
If you are prepared to give up most of the sanity checks, see this at the bottom of read.table: ## this is extremely underhanded ## we should use the constructor function ... ## don't try this at home kids class(data) - data.frame row.names(data) - row.names data

Re: [R] Quicker way of combining vectors into a data.frame

2006-11-30 Thread Sebastian Weber
Hi! I don't know for sure - and I have not tried it yet, but how about allocating a matrix which will hold all stuff, then put all vectors in it and at last assign some dimnames to it: data - matrix(0, ncol=5, nrow=length(vec1)) data[1,] - vec1 ... dimnames(data) - list(c(1,2,3,4,5), )

Re: [R] Quicker way of combining vectors into a data.frame

2006-11-30 Thread Marc Schwartz
Gavin, One more note, which is that even timing the direct data frame creation on my system with colnames, again using the same 10 numeric columns, I get: system.time(DF1 - data.frame(lc.ratio = Col1, Q = Col2, fNupt = Col3, rho.n = Col4, rho.s = Col5,