【发布时间】:2023-03-23 04:18:01
【问题描述】:
我有一个 zip 文件,其中包含私人 Github 存储库中的数据。我正在编写一些 R 代码,我希望将数据下载到 R 中。当我运行以下代码时,我得到一个 HTTP 状态为“404 Not Found”。但是,当 repo 公开时,就不会发生这种情况。
如何修复代码以下载文件?我相信我需要获取访问令牌,但我也不知道如何获取它并将其添加到代码中。如果有人可以提供帮助,我将不胜感激。谢谢。
# We give the url a name
url <- "https://github.com/aquijanoruiz/disability_benefits_EC/raw/master/ENSANUT_datasets/BDD_ENSANUT_2018_STATA_.zip"
# We create a temporary directory
td <- tempdir()
# We create the placeholder file
tf <- tempfile(tmpdir=td, fileext = ".zip")
# We download the data into the placeholder file
download.file(url,tf)
【问题讨论】:
-
有没有机会让它发挥作用?
-
无法正常工作。将文件上传到我的谷歌驱动器,不需要令牌,只需 url。感谢您的提问。
-
好的,谢谢您的反馈。我已将您的解决方法包含在答案中以获得更多可见性。