[R] write.csv and col.names=F
Don MacQueen
macq at llnl.gov
Fri Dec 18 17:09:04 CET 2009
At 9:37 PM +0800 12/18/09,
=?UTF-8?B?UmVleWFybl/mnY7mmbrmtItfMTA5MjgxMTM=?= wrote:
>On Fri, Dec 18, 2009 at 7:52 AM, kayj <kjaja27 at yahoo.com> wrote:
>>
>> Hi All,
>>
>> I always have a problem with write.csv when I want the column names to be
>> ignored, when I specify col.names=F, I get a header of V1 V2 V3 V4 etc.
>>
>
>I tried that and found the same problem, however, I found
> write.table(mydata, file="data.csv",col.names=F)
>works.
>
>write.csv calls write.table to save data, is there something wrong with it?
No.
If you read the help page you will find that it answers your question. It says:
'write.csv' and 'write.csv2' provide convenience wrappers for
writing CSV files. They set 'sep', 'dec' and 'qmethod', and
'col.names' to 'NA' if 'row.names = TRUE' and 'TRUE' otherwise.
Notice that it sets col.names for you.
If you want full control, use write.table().
If you want to write a table in a commonly used and pre-defined
format (and without having to worry about various options) use
write.csv().
That's why it is a called "convenience wrapper".
-Don
>--
>Best Regards,
>Reeyarn T. Lee
>
>______________________________________________
>R-help at r-project.org 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.
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
More information about the R-help
mailing list