From edd at debian.org  Thu Mar  6 11:46:31 2003
From: edd at debian.org (Dirk Eddelbuettel)
Date: Thu Mar  6 18:46:43 2003
Subject: [Rd] write.table row.names and col.names (PR#2610)
In-Reply-To: <200303061741.h26Hfcn9029108@pubhealth.ku.dk>
References: <200303061741.h26Hfcn9029108@pubhealth.ku.dk>
Message-ID: <20030306174631.GA2748@sonny.eddelbuettel.com>

On Thu, Mar 06, 2003 at 06:41:38PM +0100, w.huber@dkfz.de wrote:
> When data.frames are written to a file using write.table and with row.names and
> col.names, then the colnames are displaced by 1 with respect to column content.
> Example:
> 
> 
> > x = data.frame(
> >   obscht=c("chriesi", "bire"),
> >     gmues=c("chrut","hoerdoepfl"))
> > rownames(x) = c("huet", "morn")
> > write.table(x, file="test.txt", sep="\t", quote=F)
> 
> The table x now looks like:
> > x
>       obscht      gmues
> huet chriesi      chrut
> morn    bire hoerdoepfl
> 
> but the file is as follows, and the column names will be confused when reading
> this file e.g. from Excel.
> 
> obscht	gmues
> huet	chriesi	chrut
> morn	bire	hoerdoepfl

AFAIK that is a feature. Look at the example(write.table), it does precisely
this and gets data back and forth to Excel.  

Dirk

-- 
Prediction is very difficult, especially about the future. 
				             -- Niels Bohr


[Rd] write.table row.names and col.names (PR#2610)
Dirk Eddelbuettel