我试图使我的研究可重现,将数据存储在figshare。
当我下载并解压缩 R 中的数据时,发生了一些奇怪的事情。
这是 zip
如果我手动下载它,它打开正常;但是当我尝试使用R脚本获取它时,下载的存档已损坏。任何想法问题出在哪里?
重现我的错误的代码
url <- 'https://ndownloader.figshare.com/files/4797355'
path <- 'test/missing_data_raw.zip'
ifelse(file.exists(path1), yes = 'file alredy exists', no = download.file(url1, path1))
unzip(zipfile = path1,exdir = 'test')
Run Code Online (Sandbox Code Playgroud)
尝试将下载模式显式设置为二进制:
url <- 'https://ndownloader.figshare.com/files/4797217'
path1 <- tempfile(fileext = ".zip")
if (file.exists(path1)) 'file alredy exists' else download.file(url, path1, mode="wb")
unzip(zipfile = path1,exdir = tempdir())
Run Code Online (Sandbox Code Playgroud)