'R write.csv has weird formats in Notepad
I’m doing a very simple write.csv() after manipulating strings and dates.
Everything looks good in the csv file but when I open in notepad the date format changes and there are quotes around everything.
Is there something I can do in R to prevent this?
Solution 1:[1]
As a first step/guess without seeing the code I'd think it would be due to the type/class that R has assigned to the columns in your dataframe. Are they of type chr or int or other?
Solution 2:[2]
First we need to see some of your code to actually figure out what the problem is and how to solve it.
Can you give us a reproducible example of the code you are using and the output you are getting?
As an aside, I would recommend the readr::write_csv
function which has ~better~ options for output than the write.csv base R function in my humble opinion. In the documentation of this function, you can see that you can adjust when quotes are used in output.
readr::write_csv(
x,
file,
na = "NA",
append = FALSE,
col_names = !append,
quote = c("needed", "all", "none"),
escape = c("double", "backslash", "none"),
eol = "\n",
num_threads = readr_threads(),
progress = show_progress(),
path = deprecated(),
quote_escape = deprecated()
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user14836563 |
Solution 2 | Nick Camarda |