在包含数据的单元格周围生成一个没有撇号的文本文件
Generate a text file without apostrophe around my cells containing data
我有一个类似于以下示例的数据框:
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"))
}
有没有办法删除我的文本文件中的撇号“”?
哦,重要提示:
我使用相同的循环也编写了类似的文本文件,这不会在文本文件中生成撇号。所以它一定与我猜想的一列中的逗号分隔数据有关......因为这是唯一的区别。
我希望我提供了足够的信息,并清楚地说明了我的问题。谢谢
我认为只要在调用 write.table
时设置 quotes=FALSE
就可以解决这个问题:
write.table(df.t.max8[,i],
row.names = FALSE,
col.names = FALSE,
file=paste0(names(df.t.max8)[i],".txt"),
quote = FALSE)
.....
我有一个类似于以下示例的数据框:
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"))
}
有没有办法删除我的文本文件中的撇号“”?
哦,重要提示:
我使用相同的循环也编写了类似的文本文件,这不会在文本文件中生成撇号。所以它一定与我猜想的一列中的逗号分隔数据有关......因为这是唯一的区别。
我希望我提供了足够的信息,并清楚地说明了我的问题。谢谢
我认为只要在调用 write.table
时设置 quotes=FALSE
就可以解决这个问题:
write.table(df.t.max8[,i],
row.names = FALSE,
col.names = FALSE,
file=paste0(names(df.t.max8)[i],".txt"),
quote = FALSE)
.....