trying again: [R] write.table when keeping column headers (names of Columns in matrix) and row numbers
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Jun 22 23:19:56 CEST 2004
On Tue, 22 Jun 2004, Peter Wilkinson wrote:
> Actually .... I was not clear .... I will rephrase
>
> I read what is posted below in the help file already ... I read them often.
But you have not understood it. Here is an actual example:
> library(MASS)
> write.table(hills, col.names=NA)
"" "dist" "climb" "time"
"Greenmantle" 2.5 650 16.083
"Carnethy" 6 2500 48.35
"Craig Dunain" 6 900 33.65
"Ben Rha" 7.5 800 45.6
"Ben Lomond" 8 3070 62.267
"Goatfell" 8 2866 73.217
...
As I at least can see, the column names do start in the second column, and
the row names are there.
> ****I want to keep the row references****
>
> My question is _when you keep the row names_, why is the command
> write.table implemented in such a way that the column names are left
> shifted starting in the column where the row names are written?
That is not true if col.names=NA.
> Does it
> not make sense to have the column names where they are supposed to be,
They are where they are supposed to be, *as documented*
> starting in the second column, if the column names _are_ included in the
> first column?Is there a feature in this that I am missing; why is it
> implemented in this way?
So read.table can read the table in what is a standard format.
> Peter
>
>
> At 04:00 PM 6/22/2004, Prof Brian Ripley wrote:
> > From the details of ?write.table (and in the Data Import/Export manual
> >and in MASS4 ...)
> >
> > Normally there is no column name for a column of row names. If
> > 'col.names=NA' a blank column name is added. This can be used to
> > write CSV files for input to spreadsheets.
> >
> >What can we possible do to make this more obvious?
> >
> >On Tue, 22 Jun 2004, Peter Wilkinson wrote:
> >
> > > When using the write.table (say for a tab delimited file) command on a
> > > matrix with Row and Columns, the column headers are always being left
> > > shifted into the column where the row numbers are being placed. One can
> > see
> > > this when you open up the tab delimited file in excel.
> > >
> > > Is there a better command for this, or is this supposed to be a 'feature'.
> >
> >It is a genuinely useful feature, fully documented.
> >
> >--
> >Brian D. Ripley, ripley at stats.ox.ac.uk
> >Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> >University of Oxford, Tel: +44 1865 272861 (self)
> >1 South Parks Road, +44 1865 272866 (PA)
> >Oxford OX1 3TG, UK Fax: +44 1865 272595
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list