简体   繁体   中英

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'
  • scp package to remote machine
  • 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')

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. One is owned by root so we shouldn't deploy here. The other location rserve2 has owndership and looks promising. We should create a library subfolder to store the shared packages.

Based on this information, the work flow should be:

  • Create custom package 'my_package_0.1.0.tar.gz'
  • scp package to remote machine
  • create Remote session
  • install.packages("/path/to/my_package0.1.0.tar.gz", lib='/opt/deployr/9.0.1/rserve/R/library/' )
  • library('my_package')

When others connect to the machine, they can load the shared library:

  • library('my_package')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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