简体   繁体   English

使用 R 或 Rmd 从 github 存储库仅下载 *.Rmd 文件

[英]Download only *.Rmd files from a github repository using R or Rmd

I would like to download all of the *.Rmd files in a github repository.我想下载 github 存储库中的所有 *.Rmd 文件。

For a simple example, say I wanted to use R or an Rmd file to download all of the *.Rmd files in this repo:举个简单的例子,假设我想使用 R 或 Rmd 文件来下载此 repo 中的所有 *.Rmd 文件:

https://github.com/maelle/rmd-blogging-course https://github.com/maelle/rmd-blogging-course

I tried using a bash chunk in my Rmd file and wget , but wasn't able to get the Rmd files:我尝试在我的 Rmd 文件和wget中使用bash块,但无法获取 Rmd 文件:

#\```{bash}
wget -r -k --accept *.Rmd https://github.com/maelle/rmd-blogging-course
#\```

I've seen this previous question on how to download an entire repo, but I'm after only the files of a certain extension.我已经看过这个关于如何下载整个回购的问题,但我只关注某个扩展名的文件。

How to download entire repository from Github using R? 如何使用 R 从 Github 下载整个存储库?

You should use Git to clone the repository, or if you only need one revision, you can download a tarball or a zip file, the latter of which you can access from the button that says “Code”.您应该使用 Git 来克隆存储库,或者如果您只需要一个修订版,则可以下载 tarball 或 zip 文件,后者可以通过“代码”按钮访问。 As far as just downloading the *.Rmd files, GitHub doesn't provide a way to recursively download a large amount of files without cloning or downloading a tarball or zip file.就仅下载*.Rmd文件而言,GitHub 没有提供一种无需克隆或下载 tarball 或 zip 文件即可递归下载大量文件的方法。

While there are raw file endpoints, they won't work with wget --recursive because there are no directories.虽然有原始文件端点,但它们不能与wget --recursive一起使用,因为没有目录。 Trying to do so anyway would likely cause you to get rate-limited and possibly flagged, since those endpoints aren't intended for bulk download.无论如何尝试这样做可能会导致您受到速率限制并可能被标记,因为这些端点不适合批量下载。 A tarball or zip file will also likely be much faster as well. tarball 或 zip 文件也可能会快得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM