[Rd] write.csv ignores 'row.names'
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Nov 24 18:32:11 CET 2005
On Thu, 24 Nov 2005, Roger Peng wrote:
> Okay, upon further examination, it appears that it works fine if you set
> 'row.names = FALSE' as opposed to 'row.names = F'.
Yes. Adding eval.parent() (not eval()) would be better, though, as it
would allow a variable (like F) to be used. I rather like the poetic
justice of 'F' not working since no developer would have tested that,
> Roger Peng wrote:
>> Upon replying to this email, I took a look at 'write.csv()' and noticed
>> something interesting. I remember there being a discussion sometime in
>> the past about letting 'write.csv()' accept the 'row.names' argument.
>> However, I get the following error:
>> > write.csv(airquality, file = "myfile.csv", row.names = F)
>> Error in write.table(airquality, file = "myfile.csv", row.names = F,
>> col.names = NA, :
>> col.names = NA makes no sense when row.names = FALSE
>> In 'write.csv()' there is
>> rn <- Call$row.names
>> Call$col.names <- if (is.logical(rn) && !rn)
>> but is.logical(rn) is always FALSE because even if 'row.names' is
>> specified (non-NULL), it is of class "name". Perhaps something like
>> rn <- eval(Call$row.names)
>> would suffice? I can't tell if that would break anything.
>> Sven Schaltenbrand wrote:
>>> i have a problem by writing a csv file
>>> the first colum is filled with index numbers from 1 to n.
>>> i have to unique two csv files once a week while one file is always the
>>> can anybody tell me, how to write the dataset into a csv file without the
>>> first row of the indexnumbers.
>>> x[,-1] does not wok as it eliminates the first "interesting" colum.
>>> col.names is not accepted by r (do i habe to start a package first? which
>>> [[alternative HTML version deleted]]
>>> R-devel at r-project.org mailing list
> R-devel at r-project.org mailing list
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-devel