简体   繁体   English

从源代码重新加载自定义R包

[英]Reload Custom R Package from Source

I have created a custom package and would like to deploy it to a remote machine. 我创建了一个自定义程序包,并希望将其部署到远程计算机上。 Here is my current long workflow: 这是我当前的冗长工作流程:

  • Create custom package 'my_package_0.1.0.tar.gz' 创建自定义包“ my_package_0.1.0.tar.gz”
  • scp package to remote machine scp包到远程计算机
  • create Remote session 创建远程会话
  • install.packages("/path/to/my_package0.1.0.tar.gz")
  • library('my_package')

When others connect to the machine, they have to run install and library: 当其他人连接到计算机时,他们必须运行安装和库:

  • install.packages("/path/to/my_package0.1.0.tar.gz")
  • library('my_package')

Is there a way I can share a custom package and have the workflow be: 有没有一种方法可以共享自定义程序包并使工作流程为:

  • Create remote session 创建远程会话
  • Load package with library('my_package') library('my_package')加载包library('my_package')

Feedback in comments says the best practice is to install the package in a shared location. 意见反馈指出,最佳做法是将软件包安装在共享位置。

Here is how you can find a good place to install the packages. 这是您找到安装软件包的好地方的方法。

Running the following shows where libraries are loaded from 运行以下命令显示从何处加载库

.libPaths()
# rserve2 rserve2 /opt/deployr/9.0.1/rserve/R
#root root        /usr/lib64/microsoft-r/3.3/lib64/R/library

There are two locations the R server is looking for libraries. R服务器正在寻找库的两个位置。 One is owned by root so we shouldn't deploy here. 一个由root拥有,因此我们不应该在这里部署。 The other location rserve2 has owndership and looks promising. rserve2的另一个位置拥有所有权,并且看起来很有希望。 We should create a library subfolder to store the shared packages. 我们应该创建一个library子文件夹来存储共享包。

Based on this information, the work flow should be: 基于此信息,工作流程应为:

  • Create custom package 'my_package_0.1.0.tar.gz' 创建自定义包“ my_package_0.1.0.tar.gz”
  • scp package to remote machine scp包到远程计算机
  • create Remote session 创建远程会话
  • install.packages("/path/to/my_package0.1.0.tar.gz", lib='/opt/deployr/9.0.1/rserve/R/library/' ) install.packages(“ / path / to / my_package0.1.0.tar.gz”, lib ='/ opt / deployr / 9.0.1 / rserve / R / library /'
  • library('my_package') 库( 'my_package')

When others connect to the machine, they can load the shared library: 当其他人连接到计算机时,他们可以加载共享库:

  • library('my_package') 库( 'my_package')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM