readr::write_delim() How to avoid quotation marks?

library(tidyverse)
library(readr)

# Toy data
df <- structure(list(all = c("000300000000           332686630         5654         0.50000", 
                       "000300000000           3326866300000000015654         0.50000"
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
                                                            -2L))

# Write
write_delim(df, "toy.txt", delim = " ", col_names = FALSE)

When I use the above code to write a text file, each line gets surrounded by quotation marks. How can I get rid of them(")?

"000300000000           332686630         5654         0.50000"
"000300000000           3326866300000000015654         0.50000"
"000300000000           332686630         5654         0.50000"
"000300000000           3326866300000000015654         0.50000"

I'm not sure of the actual reason, but it works correctly if you get rid of the space in between " " for the delimeter setting, making it empty, like so:

write_delim(df, "toy.txt", delim = "", col_names = FALSE)

1 Like

Many thanks! It works!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.