Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 下载文件中出错:不支持方案_R_Url_Plyr - Fatal编程技术网

R 下载文件中出错:不支持方案

R 下载文件中出错:不支持方案,r,url,plyr,R,Url,Plyr,我需要从“”下载一些csv文件 这是我的密码 url <- "http://www.elections.state.md.us/elections/2012/election_data/index.html" # recognize the links links <- getHTMLLinks(url) filenames <- links[str_detect(links,"_General.csv")] filenames_list <- as.list(filen

我需要从“”下载一些csv文件

这是我的密码

url <- "http://www.elections.state.md.us/elections/2012/election_data/index.html"
# recognize the links
links <- getHTMLLinks(url)
filenames <- links[str_detect(links,"_General.csv")]
filenames_list <- as.list(filenames)
filenames
# create a function
downloadcsv <- function(filename,baseurl,folder){
  dir.create(folder,showWarnings = FALSE)
  fileurl <- str_c(baseurl,filename)
  if(!file.exists(str_c(folder,"/",filename))){
    download.file(fileurl,
                  destfile = str_c(folder,"/",filename))
    # 1 sec delay between files
    Sys.sleep(1)
  }
}
library(plyr)
l_ply(filenames_list,downloadcsv,
      baseurl = "www.elections.state.md.us/elections/2012/election_data/",
      folder = "elec12_maryland")

url事实证明,url必须以一个方案开始,例如http://、https://、ftp://或file://。所以在最后一行,我把代码改为

l_ply(filenames_list,downloadcsv,
      baseurl = "http://www.elections.state.md.us/elections/2012/election_data/",
      folder = "elec12_maryland")

它是有效的

事实证明,url必须以一个方案开头,例如http://、https://、ftp://或file://。所以在最后一行,我把代码改为

l_ply(filenames_list,downloadcsv,
      baseurl = "http://www.elections.state.md.us/elections/2012/election_data/",
      folder = "elec12_maryland")
它是有效的