Re: [R] Create data frame from header only

2008-08-04 Thread Prof Brian Ripley
On Mon, 4 Aug 2008, Etienne B. Racine wrote: Even if it's not so elegant, I will bind it in a function, so I don't have to bother with that anymore. I think there should be a simple function in R to initialize an empty data frame. From what I've read, it is a recurrent question on that list.

Re: [R] Create data frame from header only

2008-08-04 Thread Henrik Bengtsson
See dataFrame() in R.utils. It was design for the purpose of allocating empty data frames in an efficient way. Example: > library(R.utils); > df <- dataFrame(colClasses=c(a="integer", b="double"), nrow=10); > str(df) 'data.frame': 10 obs. of 2 variables: $ a: int 0 0 0 0 0 0 0 0 0 0 $ b: n

Re: [R] Create data frame from header only

2008-08-04 Thread Etienne B. Racine
Even if it's not so elegant, I will bind it in a function, so I don't have to bother with that anymore. I think there should be a simple function in R to initialize an empty data frame. From what I've read, it is a recurrent question on that list. #Create an empty data frame from a header list em

Re: [R] Create data frame from header only

2008-08-04 Thread Marc Schwartz
on 08/04/2008 07:40 PM Etienne Bellemare Racine wrote: Hi all, Given a string list, > paste("A",1:5,sep="") [1] "A1" "A2" "A3" "A4" "A5" I would like to create an empty data frame using that list as the header, so I can access my data frame column using, > df [ list [ i ] ] Anyon

Re: [R] Create data frame from header only

2008-08-04 Thread milton ruser
Hi Etienne It is not so elegant, bu I think that work. colname.list<-paste("A",1:5,sep="") df<-data.frame(matrix(matrix(rep(1,length(colname.list)),1),1)) df colnames(df)<-colname.list df df<-df[-1,] df Cheers, Miltinho Astronauta Brazil On 8/4/08, Etienne Bellemare Racine <[EMAIL PROTECTE

[R] Create data frame from header only

2008-08-04 Thread Etienne Bellemare Racine
Hi all, Given a string list, > paste("A",1:5,sep="") [1] "A1" "A2" "A3" "A4" "A5" I would like to create an empty data frame using that list as the header, so I can access my data frame column using, > df [ list [ i ] ] Anyone ? Thanks, Etienne [[alternative HTML version