Considering the following string:
my_string <- c('this is "my_string", it uses "double-"qoutes" because"" I need them"')
write.table(my_string, "my_string.txt")
When I open the my_string.txt
file the output is exactly the following:
"x"
"1" "this is \"my_string\", it uses \"double-\"qoutes\" because\"\" I need them\""
Basically it added "x" and "1" and the most annoying thing are the back-slash () present in all the file.
How can I avoid this annoying thing?
Use row.names=F
, col.names=F
and quote=F
That is:
write.table(my_string, "my_string.txt",quote=F,row.names=F, col.names=F)
?write.table
for more options
Another possible approach I found somewhere is:
fileConn<-file("my_string.txt")
writeLines(my_string, fileConn)
close(fileConn)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.