我希望从网址中打开多个文件,这些文件遵循以下一致的顺序:
file001=read.table("https://...file_001.dat")
file002=read.table("https://...file_002.dat")
file003=read.table("https://...file_003.dat")
如何创建一段代码,以这样的顺序打开多个连续的Web文件?
答案 0 :(得分:0)
df3 <- setDT(df)[, m.test := rleid(date), by = group]
group date m.test
1: A 2016-10-06 11:56:00 1
2: A 2016-10-05 11:56:00 2
3: A 2016-10-05 11:56:00 2
4: A 2016-10-07 11:56:00 3
5: B 2016-10-06 11:56:00 1
6: B 2016-10-05 11:56:00 2
7: B 2016-10-05 11:56:00 2
8: B 2016-10-07 11:56:00 3
将您的修改发布到问题
path="/path/to/all_webfiles"
x=list.files(path = path, pattern = ".dat")
final_pathname = paste0(path, x)
L=lapply(seq_along(final_pathname), function(i) read.table(final_pathname[i]))
此处i <- 1:10 # assuming only 10 files
l <- lapply(seq_along(i), function(j) read.table(paste0("http://file00", j)))
将包含每个数据框,前提是您的网络链接正确且有效!