Jon Ferreira
Jon Ferreira

Reputation: 23

Writing table to file using R results in unwanted row names column

I'm attempting to use R to merge data columns into one tab-delimited matrix. When I use the cbind() function, R for some reason adds a first column specifying row numbers, even though I did not include such column as an argument. For example, when I use cbind() on the following columns:

x|y|z
x|y|z
x|y|z

cbind() yields:
1|x|y|z
2|x|y|z
3|x|y|z

I've tried deleting that first column using subsets and a few other methods I've come across. No matter what I do, when I write this matrix to a .txt file, the row numbers still show up as an additional column (so when opening in excel, you not only see the row numbers provided by excel, but an additional row from the generation of this txt file). I could manually remove them in excel, but this is not really feasible with the amount of tables I plan on generating.

Upvotes: 2

Views: 4877

Answers (1)

Matthew Plourde
Matthew Plourde

Reputation: 44614

Set the row.names argument to FALSE in write.table.

Upvotes: 8

Related Questions