-1

My input data is:

X, occupation ,  focc   , education  ,  race
1, 1 , sales  , professional ,  14  ,    non-black
2, 2 , craftsmen , sales    ,   13   ,    non-black
3, 3  ,  sales  ,  professional 16    ,    non-black

I delete the x column and save, but the unmodified state gets saved:

data <- read.csv("gss.csv")
data$X <- NULL
head(data)  
write.csv(data,file = "puregss.csv")

The unmodified state was saved:

head(read.csv("puregss.csv"))

I expected this output:

occupation ,  focc   , education  ,  race
1 , sales  , professional ,  14  ,    non-black
2 , craftsmen , sales    ,   13   ,    non-black
3  ,  sales  ,  professional 16    ,    non-black
smci
  • 32,567
  • 20
  • 113
  • 146
Enes
  • 41
  • 1
  • 10
  • Welcome to SO. Please edit your question to [fix the formatting and indent code](https://stackoverflow.com/help/how-to-ask), it's almost illegible. Also it's unclear what your current and expected input and output are. – smci Apr 05 '19 at 08:32
  • I added the first and final version of the expected data – Enes Apr 05 '19 at 08:40
  • Try `write.csv(data, "puregss.csv", row.names = FALSE)` ? – ophdlv Apr 05 '19 at 08:46
  • It was that simple. Thank you @Pelilican – Enes Apr 05 '19 at 08:51
  • Possible duplicate of [R - write to file without colum 0 (write.csv or write.table)](https://stackoverflow.com/questions/38956981/r-write-to-file-without-colum-0-write-csv-or-write-table) – camille Apr 05 '19 at 14:11

1 Answers1

1
write.csv(data, "puregss.csv", row.names = FALSE)
Enes
  • 41
  • 1
  • 10