How to avoid extra column when writing a csv file?
Asked Answered
T

1

9
# saving the work as ... data_full.csv
write.csv(data.full, "data_full.csv", col.names = TRUE)

#importing file
data.dir <- file.choose()
data <- read.csv(data.dir, header = TRUE)

data.full was written as

enter image description here

but data got read as

enter image description here

Can anyone suggest me a solution, on how to solve this simple problem?

Tenpins answered 18/8, 2017 at 11:58 Comment(4)
In your write.csv statement use the option row.names=FALSESynthiasyntonic
thought it was FALSE by default. Thanks for that, it solve the problem. Do I delete this post?Tenpins
No, best to leave it in case somebody else has the same issue.Synthiasyntonic
@AndrewGustar - If the question is to be left, please add your response as an answer so that the question does not go unanswered.Oxidimetry
S
16

In your write.csv statement use the option row.names=FALSE to suppress the first column - it is on by default.

Synthiasyntonic answered 18/8, 2017 at 13:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.