在具有相同名称的CRAN包旁边安装github包?

时间:2017-04-21 21:29:36

标签: r git github sf

有没有合理的方法来安装CRAN包以及同名的github包?

具体来说,我在geom_sf() github页面https://github.com/tidyverse/ggplot2/tree/sf中的sf分支中的ggplot2 geom之后。所以我可以像这样安装sf分支:

devtools::install_github("tidyverse/ggplot2", ref = "sf")

这样的CRAN版本:

install.packages("ggplot2")

但是,sf分支在其他有用功能的ggplot2后面,所以我不想完全恢复。所以我想知道最好的方法是什么。我可以安装两个但不知何故调用一个包ggplot2_sf?基本上我希望能够将geom_sf与当前在CRAN上的ggplot2的所有功能一起使用。

我原以为可能最好的解决方案是分叉ggplot2 repo,合并master和sf分支然后安装它。但我想知道是否有更好的方法?

更新

所以事实证明你需要使用withr指定lib目录(参见here)。我试过这个:

withr::with_libpaths(new = "./R/gh_libs/", install_github("tidyverse/ggplot2", ref = "sf"))

这返回了这个错误:

  

curl :: curl_fetch_disk(url,x $ path,handle = handle)出错:
  SSL CA证书问题(路径?访问权限?)

所以我可以将SSL认证设置为零:

httr::set_config( httr::config( ssl_verifypeer = 0L ) )
withr::with_libpaths(new = "./R/gh_libs/", install_github("tidyverse/ggplot2", ref = "sf"))

但是,这并没有将它安装在我之后的目录中:

  

从URL下载GitHub repo tidyverse / ggplot2 @sf   https://api.github.com/repos/tidyverse/ggplot2/zipball/sf安装   ggplot2安装1包:摘要警告   utils :: install.packages(pkgs,repos = repos,type = type,dependencies   =依赖项,:' lib =" C:/ Program Files / R / R-3.3.3 / library"'是不可写的utils :: install.packages中的错误(pkgs,repos = repos,   type = type,dependencies = dependencies,:无法安装   封装

我可能做错了什么其他的想法?

1 个答案:

答案 0 :(得分:1)

您可以使用devtools::dev_mode()。从手册页:

  

激活后,dev_mode会创建一个用于存储已安装软件包的新库。如果dev_mode尚不存在,则会在激活dev_mode时自动创建此新库。这允许您在沙箱中测试开发包,而不会干扰您已安装的其他软件包。