> -----Original Message-----
> From: X.H Chen [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, September 24, 2006 12:16 AM
> To: [EMAIL PROTECTED]; [email protected]
> Subject: Re: [R] Data frames questions
> 
> 
> >1) Is there a way to build an empty data frame, containing 
> nothing but 
> >the data frame variable names?
> 
> Yes, you can do it one way as followings:
> 
> df1<-as.data.frame(matrix(nrow=2,ncol=2),row.names=c("R1","R2"))

This results in a dataframe with two rows and two columns NA in it.
In order to build an empty dataframe one you could use:

df1 <- data.frame( X1=1, x2=3, l1=TRUE, d3=as.Date("2003-07-14")
)[NULL,]
str( df1 )

The key is the "NULL" for the rows, it removes the data but keeps the
content.

Best,
Bendix
----------------------
Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 30 75 87 38
fax: +45 44 43 07 06
[EMAIL PROTECTED]
www.biostat.ku.dk/~bxc
----------------------
 
(snip)

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to