The argument is "col.names", not "colnames".

Best,
Ista
On Mar 19, 2014 6:14 AM, "Luca Cerone" <luca.cer...@gmail.com> wrote:

> Hi everybody,
> I am sorry if this is a silly question (I have tried to search it at
> http://tolstoy.newcastle.edu.au/R/ but I get a 404 page).
>
> I have a script writing some data.frames to csv files.
> I write the csv files using the write.csv function and the option
> row.names=TRUE.
> Everything works fine, except that I am not able to set the name of
> the column holding the row.names.
>
> For example I tried to set the column name to ID like this:
>
>     df = data.frame(a=c(1,2,3), b=c(3,4,5))
>     rownames(df) = c("A","B","C")
>
>     write.csv(df, row.names=TRUE, colnames=c("ID", colnames(df)))
>
> This fails with the following error:
>     Error in write.table(df, row.names = TRUE, colnames = c("ID",
> colnames(df)),  :
>           unused argument (colnames = c("ID", colnames(df)))
>
> How can I do this? I have tried to use write.table() as well, but it
> seems I never get to set the options right.
>
> Thanks a lot in advance for the help,
>
> Cheers,
> Luca
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to