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 deleted]]
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 PROTECTED]
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 ] ]
Anyone ?
Thanks,
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
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: num 0 0
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.
6 matches
Mail list logo