我有一个类似于以下示例的数据框:
structure(list(`t-001` = c("19790101", "19.25,11.09", "21.02,10.77",
"21.02,10.21", "20.31,9.94", "20.84,9.9"), `t-002` = c("19790101",
"21.19,11.08", "22.53,12.22", "22.64,11.64", "22.42,11.49", "22.01,10.74"
)), .Names = c("t-001", "t-002"), row.names = c(NA, 6L), class = "data.frame")
t-001 t-002
1 19790101 19790101
2 19.25,11.09 21.19,11.08
3 21.02,10.77 22.53,12.22
4 21.02,10.21 22.64,11.64
5 20.31,9.94 22.42,11.49
6 20.84,9.9 22.01,10.74
当我生成文本文件时,我想看到的是,以t-001作为文本文件名:
19790101
19.25,11.09
21.02,10.77
21.02,10.21
20.31,9.94
20.84,9.9
但是我得到的是:
"19790101"
"19.25,11.09"
"21.02,10.77"
"21.02,10.21"
"20.31,9.94"
"20.84,9.9"
我使用以下循环来生成我的文本文件:
# loop writing text files, for 32 columns, without column and row names, and use the columnnames as text file names.
for(i in c(1:32)){
write.table(df[,i],row.names = FALSE, col.names = FALSE,file=paste0(names(df)[i],".txt"))
}
有没有办法删除我的文本文件中的撇号“”?
哦,一个重要的提示:
我使用相同的循环来编写类似的文本文件,这不会在文本文件中生成撇号。所以我猜它一定与一列中逗号分隔的数据有关......因为这是唯一的区别。
我希望我提供了足够的信息,并清楚地说明了我的问题。谢谢