【发布时间】:2015-12-05 00:16:02
【问题描述】:
我需要下载 300 多个在线可用的 .csv 文件,并将它们组合成 R 中的数据框。它们都具有相同的列名,但长度(行数)不同。
l<-c(1441,1447,1577)
s1<-"https://coraltraits.org/species/"
s2<-".csv"
for (i in l){
n<-paste(s1,i,s2, sep="") #creates download url for i
x <- read.csv( curl(n) ) #reads download url for i
#need to sucessively combine each of the 3 dataframes into one
}
【问题讨论】:
-
read.csv接受网址:tmp <- do.call('rbind', tmp1 <- Vectorize(read.csv, SIMPLIFY = FALSE)(paste0(s1, l, s2)))其中tmp1将包含您的数据框列表,tmp将它们组合在一起
标签: r url for-loop download dataframe