Ama N. answered 11/10/22
R Programmer | Data Scientist | Data Visualization Designer
By default, row names are included when you export a data frame to a CSV file with the write.csv() function. To turn off this option, set the row.names argument within the function to FALSE. (This argument tells R not to include the row names when creating (or exporting) the data frame.)
For example:
Let's assume you have a data frame called t:
t <- data.frame(v = 5:1, v2 = 9:5)
To export t to the current working directory without row names, write:
write.csv(x = t, file = "t.csv", row.names = FALSE)
Where x is the data frame you want to export; file is the filename (including extension; .csv in this case) you assign to the exported data frame; and the row.names argument is set to FALSE.