Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top