theBotelho
theBotelho

Reputation: 324

How to avoid extra column when writing a csv file?

# 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?

Upvotes: 9

Views: 15814

Answers (1)

Andrew Gustar
Andrew Gustar

Reputation: 18445

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

Upvotes: 16

Related Questions