Home Forums Main Forums R Forum Create pipe-delimited files in R

  • Create pipe-delimited files in R

     Datura updated 3 years, 4 months ago 1 Member · 1 Post
  • Datura

    Member
    November 27, 2020 at 8:24 pm
    Up
    0
    Down

    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 3 years, 4 months ago by  Datura.

Log in to reply.

Original Post
0 of 0 posts June 2018
Now