【发布时间】:2013-05-28 05:46:08
【问题描述】:
我正在尝试读取多个文件,然后将它们组合成一个数据帧。我使用的代码如下:
library(plyr)
mydata = ldply(list.files(path="Data load for stations/data/Predicted",pattern = "txt"), function(filename) {
dum = read.table(filename,skip=5, header=F, sep=" ")
#If you want to add the filename as well on the column
dum$filename = filename
return(dum)
})
我得到的错误如下:
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'mobdata201001.txt': No such file or directory
数据文件可以在https://www.dropbox.com/sh/827kmkrwd0irehk/BFbftkks42找到
非常感谢任何帮助。
【问题讨论】:
-
您是否尝试过仅使用您提供的路径和文件名加载一个文件?您收到的错误似乎找不到文件。也许只是在路径中添加一个额外的“/”?
-
如果这些是与动物园一致的时间序列,那么
read.zoo可以读取多个文件,从中创建一个动物园对象。