Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

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.

For a simple example, say I wanted to use R or an Rmd file to download all of the *.Rmd files in this repo:

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:

#```{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?

question from:https://stackoverflow.com/questions/65912533/download-only-rmd-files-from-a-github-repository-using-r-or-rmd

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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”. 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.

While there are raw file endpoints, they won't work with wget --recursive because there are no directories. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...