0

Suppose I have the following dataset, dat:

     Name   Account No. Occupation
     Marie  7672        Nurse
     Jerry  0986        Veterinarian
     Max    3927        Hairdresser

I output a dataset, named "dat" using the following codes:

write.table(dat, file = paste(date, 'output.txt'), na ="", row.names = FALSE, append = TRUE, sep = '\t')

output.txt looks like

     "Name"     "Account No."    "Occupation"
     "Marie"    7672    "Nurse"
     "Jerry"    0986    "Veterinarian"
     "Max"    3927    "Hairdresser"

How do I remove the double quotes in the final output?

Harshal Parekh
  • 5,918
  • 4
  • 21
  • 43
  • I believe it would be useful for you to check out function gsub: http://www.endmemo.com/program/R/gsub.php – Lucas Mendonca Jan 29 '20 at 12:49
  • Does this answer your question? [Avoid quotation marks in column and row names when using write.table](https://stackoverflow.com/questions/14846433/avoid-quotation-marks-in-column-and-row-names-when-using-write-table) – Harshal Parekh Jan 29 '20 at 12:50
  • 1
    `quote = FALSE` removes quoting. Read `?write.table` – alan ocallaghan Jan 29 '20 at 13:04

1 Answers1

2
write.table(dat, file=paste(date, 'output.txt'), na ="", row.names=FALSE, append=TRUE, sep='\t', quote=FALSE)

You can use the quote parameter.

Harshal Parekh
  • 5,918
  • 4
  • 21
  • 43