yihui / xfun

Miscellaneous R functions
https://yihui.org/xfun/
Other
141 stars 28 forks source link

关于增强 `xfun::install_github()` 函数功能的建议 #61

Closed chuxinyuan closed 2 years ago

chuxinyuan commented 2 years ago

国内用户访问 GitHub 是个比较纠结的问题,即使通过修改 hosts 勉强可以访问了,但是通过 GitHub 直接安装 R 包也容易报错。我之前安装 GitHub 上的 R 包都是通过导入到 Gitee,然后通过 remotes::install_git() 来安装,但是相对比较麻烦,尤其是涉及到依赖包仍然在 GitHub 上的时候。

最近发现一个神奇的网站 https://hub.fastgit.org/,以前只是用来更快的浏览 GitHub 网站上的内容,最近发现:其实也可以通过这个网站安装 R 包,比如我要安装 xfun 包(假装这个包或者新版没有提交到 CRAN),我可以用 remotes::install_git("https://hub.fastgit.org/yihui/xfun.git") 来安装它。

综上,目前我想到几个增强 xfun::install_github() 函数功能的方案:

方案一

xfun::install_github() 函数增加一个时区判断,如果是国内用户直接从 https://hub.fastgit.org 下载源码并安装。

方案二

xfun::install_github() 函数增加一个访问 GitHub 的时长判断,一旦超过 10s 还没有开始下载,那么就不等了,直接从 https://hub.fastgit.org 下载源码并安装。

方案三

另外增加一个类似于 tinytex::tlmgr_repo() 的函数,通过一次设置,后面再安装 R 包的时候自动选择从 https://hub.fastgit.org 下载源码并安装。


By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

yihui commented 2 years ago

xfun 中的 install_github 只是个快捷方式(为了自动补全更快),无意做任何扩展开发工作。你可以考虑写个自己的扩展包。

chuxinyuan commented 2 years ago

xfun 中的 install_github 只是个快捷方式(为了自动补全更快),无意做任何扩展开发工作。你可以考虑写个自己的扩展包。

好的,我试试看!ipkg::ig() 会不会很别扭?

yihui commented 2 years ago

如果只是你自己用的包和函数,那就随你怎么命名了。如果你真的频繁使用这个函数,你也可以考虑把它放在你的 .Rprofile 中。

另外,取决于你要安装哪个 Github 库里的包,也许它已经在 r-universe.dev 中收录了,比如 xfun 就可以从那里直接安装,无须使用 install_github()https://github.com/yihui/xfun#xfun