Ink*_*ing 4 r github repository download rstudio
是否可以使用R从Github下载整个存储库?我想访问的这些文件不是.csv文件(大多数教程都教).它们是.r和.rmd文件的混合,我想单独或一次性读入R.谢谢 :)
您可以使用R分三步从GitHub下载整个存储库:
Clone or download的GitHub存储库上的按钮复制.zip URL .请务必复制链接地址,Download ZIP而不是HTTPS URL.注意:此步骤假定您对感兴趣master的GitHub存储库的分支感兴趣.如果不是这种情况,请务必导航到您有兴趣下载的分支机构.
将.zip URL粘贴到url参数中download.file()以下载感兴趣的.zip文件.由于这是一个GitHub存储库,因此分配与destfile感兴趣的存储库同名的参数(在本例中为destfile = "meetingsR-master")会很有帮助.destfile参数名称的"-master"部分来自声明您要下载的感兴趣的存储库的分支名称.
使用unzip()解压下载的zip文件.
在下面使用代码时,请注意更改文件路径.
# set working directory so I know where the .zip file will be located
setwd(dir = "/some/path/")
# download a .zip file of the repository
# from the "Clone or download - Download ZIP" button
# on the GitHub repository of interest
download.file(url = "https://github.com/jumpingrivers/meetingsR/archive/master.zip"
, destfile = "meetingsR-master.zip")
# unzip the .zip file
unzip(zipfile = "meetingsR-master.zip")
# set the working directory
# to be inside the newly unzipped
# GitHub repository of interest
setwd(dir = "/some/path/meetingsR-master/")
# examine the contents
list.files()
# [1] "_book"
# [2] "_output.yml"
# [3] "01-events.Rmd"
# [4] "02_useR_groups_aaa.Rmd"
# [5] "02_useR_groups_asia.Rmd"
# [6] "02_useR_groups_europe.Rmd"
# [7] "02_useR_groups_middle_east_africa.Rmd"
# [8] "02_useR_groups_north_america.Rmd"
# [9] "02_useR_groups_oceania.Rmd"
# [10] "02_useR_groups_south_america.Rmd"
# [11] "03-Rladies.Rmd"
# [12] "css"
# [13] "deploy.sh"
# [14] "DESCRIPTION"
# [15] "docs"
# [16] "index.Rmd"
# [17] "inverse.png"
# [18] "logo.png"
# [19] "Makefile"
# [20] "NAMESPACE"
# [21] "R"
# [22] "README.md"
# [23] "Rmeetings.Rproj"
# end of script #
Run Code Online (Sandbox Code Playgroud)
我看到这个问题有rstudio标签。您可以rstudio通过选择file-> new project-> version control->git并在Repository URL字段中输入所需 Github 存储库的地址来使用(并避免使用命令行)。
点击Create Project按钮后,rstudio将下载存储库的内容,创建一个新项目,并将您的工作目录更改为新项目。
| 归档时间: |
|
| 查看次数: |
2096 次 |
| 最近记录: |