2017-03-21 65 views
0

我想保存字符的數據幀。從保存的txt刪除「」標記

我想:

df1 <- data.frame(c1= "abc",c2="def",c3="ghi") 
df1 

write.table(df1, "df1.txt") 

但該文件包含所有以 「」 標記:

"c1" "c2" "c3" 
"1" "abc" "def" "ghi" 

我如何保存沒有""標記的文件嗎?

回答

1

設置quote=FALSE

從write.table的文檔:

write.table(x, file = "", append = FALSE, quote = TRUE, sep = " ", 
      eol = "\n", na = "NA", dec = ".", row.names = TRUE, 
      col.names = TRUE, qmethod = c("escape", "double"), 
      fileEncoding = "") 

「報價
邏輯值(TRUE或FALSE)或數字向量,如果爲TRUE,則任何字符或因子列將被雙引號包圍一個數字向量,它的元素被當作引用列的索引。在這兩種情況下,行和列名稱在寫入時都會被引用。如果FALSE,則不會引用任何內容。「

1

你可以使用該選項quote = FALSE

df1 <- data.frame(c1= "abc",c2="def",c3="ghi") 
df1 

write.table(df1, "df1.txt", quote = FALSE)