[R] Questíon regarding the use of write.csv2, write.table ...
xavier.chardon at free.fr
xavier.chardon at free.fr
Thu Jun 18 13:50:16 CEST 2009
Hi,
It sounds like the first column that is "added" is actually the row names. That's why a previous answer pointed this argumented. Default for write.csv is to write the row names along with the data. So, this should work:
write.csv2(exampleDataframe,file="exampleDataframe.csv", row.names=FALSE)
Xavier
----- Mail Original -----
De: "Lavri Labi" <lavri.labi at tu-dortmund.de>
À: "Jorge Ivan Velez" <jorgeivanvelez at gmail.com>
Cc: r-help at r-project.org
Envoyé: Jeudi 18 Juin 2009 12h35:31 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne
Objet: Re: [R] Questíon regarding the use of write.csv2, write.table ...
Dear Jorge,
thank you for the quick answer. But I am afraid you didn´t understand my
problem. I want to write the following data frame "exampleDataframe" in a
csv2-file.
"a";"b";"c";"d"
1 ; 2 ; 3 ; 4
5 ; 6 ; 7 ; 8
9 ; 0 ; 1 ; 2
After sending the command:
write.csv2(exampleDataframe,file="exampleDataframe.csv")
I become the following file:
"";"a";"b";"c";"d"
1 ; 1 ; 2 ; 3 ; 4
2 ; 5 ; 6 ; 7 ; 8
3 ; 9 ; 0 ; 1 ; 2
How can I delete the first column added, which I do not need?
The row.names you suggest me is not reallly helpful in this case.
Cheers,
Lavri
> Dear Lavri,
> Take a look at the row.names argument in ?write.table.
>
> HTH,
>
> Jorge
>
>
> On Thu, Jun 18, 2009 at 4:09 AM, Lavri Labi
> <lavri.labi at tu-dortmund.de>wrote:
>
>> Hi all,
>>
>> I use "write.csv" and "write.table" to write a data frame in a file like
>> following:
>> write.csv2(allRandomTestCase_XDroped, "allRandomTestCase.csv")
>> But in the created file "allRandomTestCase.csv" an additional column
>> with
>> consecutive numbers is automatically added to the column of the data
>> frame
>> "allRandomTestCase_XDroped".
>>
>> That is why my question, how can I write data in a file without this
>> added
>> column?
>>
>> Cheers,
>>
>> Lavri
>>
>> ______________________________________________
>> 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.
>>
>
______________________________________________
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.
More information about the R-help
mailing list