[英]avoid write.table to save R's (\) in the exported .txt file
考慮以下字符串:
my_string <- c('this is "my_string", it uses "double-"qoutes" because"" I need them"')
write.table(my_string, "my_string.txt")
當我打開my_string.txt
文件時,輸出將完全是以下內容:
"x"
"1" "this is \"my_string\", it uses \"double-\"qoutes\" because\"\" I need them\""
基本上,它添加了“ x”和“ 1”,最令人討厭的是所有文件中都存在反斜杠()。
如何避免這種煩人的事情?
使用row.names=F
, col.names=F
和quote=F
那是:
write.table(my_string, "my_string.txt",quote=F,row.names=F, col.names=F)
?write.table
獲得更多選項
我在某處找到的另一種可能的方法是:
fileConn<-file("my_string.txt")
writeLines(my_string, fileConn)
close(fileConn)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.