Home › Forums › Main Forums › R Forum › Create pipe-delimited files in R
-
In real work, when we need to export data to text files, it is highly recommended to use pipe-delimited files rather than CSV or space delimited. This is a best practice in real work.
In R, we can use the write.table() function to create pipe or other delimited files. Below shows the syntax.
write.table(df, file = "/file path/output.txt",
row.names=FALSE,
quote=FALSE,
sep = "|")The row.names=FALSE/TRUE option can tell R to keep the row names or not. quote=FALSE/TRUE is to add quotations to column names and data or not. Simplicity is the best, I suggest to use FALSE option. sep=”|” is to specify pipe as the field delimiter, you can specify other delimiters if you want.
- This discussion was modified 4 years ago by Datura.
Log in to reply.