-1

I need to convert a file of .csv format to one of .tab format. How do I go about this in R?

rkl
  • 47
  • 8
  • 3
    You can import the `csv` and write it to file using a tab separator. See `?write.table`. – Anonymous coward Sep 18 '18 at 19:55
  • 2
    `write.table(read.csv('old-file.csv'), 'new-file.tab')`, though there are a lot of other parameters you may want to consider. `readr::write_tsv` and `read_csv` are drop-in replacements with better defaults, if you like. – alistaire Sep 18 '18 at 19:59

1 Answers1

1

Copying the correct answer from the comments:

write.table(read.csv("old-file.csv", sep=","), "new-file.tab")

Note that read.csv and write.csv are just read.table and write.table with different defaults.

Also as mentioned in the comments, you might find read_csv and write_tsv from the readr package more pleasant to work with (the built-in R functions can have some surprising behavior).

shadowtalker
  • 12,529
  • 3
  • 53
  • 96