创建本地R包存储库

时间:2022-01-23 14:15:39

I would like to create a local R package repository such that users in my company can install packages from it and the system admins can update the local repo periodically. Access to the CRAN mirrors is currently denied.

我想创建一个本地R包存储库,以便我公司的用户可以从它安装包,系统管理员可以定期更新本地repo。CRAN镜像的访问目前被拒绝。

Is there a simple way to do this?

有没有一种简单的方法?

3 个解决方案

#1


38  

Yes, either a copy of CRAN or a repo with local packages is easy to set up. Presumably you want this for Windows so do this:

是的,无论是CRAN的副本还是带有本地包的repo都很容易设置。假设你想要Windows这样做:

  1. Create a top-level directory on your webserver, say R/
  2. 在web服务器上创建一个*目录,例如R/
  3. Create the usual hierarchy in there: R/bin/windows/contrib/2.11. If you need to support other (earlier) releases, simply create directories 2.10, 2.9, ... next to the 2.11 directory.
  4. 在其中创建通常的层次结构:R/bin/windows/悔过书/2.11。如果您需要支持其他(早期)版本,只需创建目录2.10、2.9、……在2.11目录旁边。
  5. Place the packages you need into the directory (say, 2.11), then change into that directory and run the following command to generate PACKAGES and PACKAGES.gz files for the repository:

    将需要的包放置到目录中(例如2.11),然后切换到该目录并运行以下命令来生成包和包。库的gz文件:

    tools::write_PACKAGES(".", type="win.binary")

    工具::write_PACKAGES(”。”,type = " win.binary”)

That is all there is to it -- now you can access the repository by pointing to the address given a command such as

这就是它的全部内容——现在您可以通过指向给定的地址(例如)访问存储库

update.packages(repos="http://my.local.server/R", ask=FALSE)

which I even do in R/zzz.R for local packages so that they update themselves.

我甚至用R/zzz。本地包的R,以便他们更新自己。

Edit some five+ years later: And the drat package now automates a lot of this, and shines particularly if you also use GitHub to serve the repository over http/https (but is useful for other or local hosting too).

大约5年以后编辑:drat包现在自动化了很多这方面的工作,如果您还使用GitHub通过http/https服务存储库(但对于其他或本地主机也很有用),这一点就显得尤为突出。

#2


18  

Read the section of the Administrator guide.

请阅读管理员指南一节。

#3


2  

The package miniCRAN also provides great functionality for this. The key advantage being that you don't need a full mirror, but can setup a "mini" mirror of CRAN with only the packages distributions you need, including their dependencies.

miniCRAN包也为此提供了很好的功能。关键的优点是您不需要一个完整的镜像,但是可以设置一个“迷你”CRAN镜像,只包含您需要的包发行版,包括它们的依赖项。

#1


38  

Yes, either a copy of CRAN or a repo with local packages is easy to set up. Presumably you want this for Windows so do this:

是的,无论是CRAN的副本还是带有本地包的repo都很容易设置。假设你想要Windows这样做:

  1. Create a top-level directory on your webserver, say R/
  2. 在web服务器上创建一个*目录,例如R/
  3. Create the usual hierarchy in there: R/bin/windows/contrib/2.11. If you need to support other (earlier) releases, simply create directories 2.10, 2.9, ... next to the 2.11 directory.
  4. 在其中创建通常的层次结构:R/bin/windows/悔过书/2.11。如果您需要支持其他(早期)版本,只需创建目录2.10、2.9、……在2.11目录旁边。
  5. Place the packages you need into the directory (say, 2.11), then change into that directory and run the following command to generate PACKAGES and PACKAGES.gz files for the repository:

    将需要的包放置到目录中(例如2.11),然后切换到该目录并运行以下命令来生成包和包。库的gz文件:

    tools::write_PACKAGES(".", type="win.binary")

    工具::write_PACKAGES(”。”,type = " win.binary”)

That is all there is to it -- now you can access the repository by pointing to the address given a command such as

这就是它的全部内容——现在您可以通过指向给定的地址(例如)访问存储库

update.packages(repos="http://my.local.server/R", ask=FALSE)

which I even do in R/zzz.R for local packages so that they update themselves.

我甚至用R/zzz。本地包的R,以便他们更新自己。

Edit some five+ years later: And the drat package now automates a lot of this, and shines particularly if you also use GitHub to serve the repository over http/https (but is useful for other or local hosting too).

大约5年以后编辑:drat包现在自动化了很多这方面的工作,如果您还使用GitHub通过http/https服务存储库(但对于其他或本地主机也很有用),这一点就显得尤为突出。

#2


18  

Read the section of the Administrator guide.

请阅读管理员指南一节。

#3


2  

The package miniCRAN also provides great functionality for this. The key advantage being that you don't need a full mirror, but can setup a "mini" mirror of CRAN with only the packages distributions you need, including their dependencies.

miniCRAN包也为此提供了很好的功能。关键的优点是您不需要一个完整的镜像,但是可以设置一个“迷你”CRAN镜像,只包含您需要的包发行版,包括它们的依赖项。