如何在离线 Debian 机器上安装 R 包? [英] How can I install a R package on a offline Debian machine?

查看:20
本文介绍了如何在离线 Debian 机器上安装 R 包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have an Debian VM which is not connected to internet. Yet, I can still scp any file from my local machine which does have internet connection. To provide a little bit context, I am trying to host an shiny app on the VM.

I can still install an old version of R 3.1.1 with the "apt-get" command:

sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev

Yet, still can't find the "shiny" package when check the list:

sudo apt-cache search "^r-.*" | sort

So, I am thinking whether I could just scp the "shiny.tar.gz" to the VM and install the package locally? How could I install any R package offline?

I have tried somethings like:

install.packages('/home/mli/R/dir_pkg/shiny/shiny_0.13.2.tar.gz', repos = NULL, type = "source")

Yet, it didn't go through and error message as below:

Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Error in type == "both" : 
comparison (1) is possible only for atomic and list types
Calls: install.packages
Execution halted

Then, I tried it with another "R CMD":

R CMD INSTALL /home/mli/R/dir_pkg/shiny/shiny_0.13.2.tar.gz

I got error message telling me that dependencies is missing:

* installing to library ‘/home/mli/R/x86_64-pc-linux-gnu-library/3.1’
ERROR: dependencies ‘httpuv’, ‘mime’, ‘jsonlite’, ‘xtable’, ‘digest’, ‘htmltools’, ‘R6’ are not available for package ‘shiny’
* removing ‘/home/mli/R/x86_64-pc-linux-gnu-library/3.1/shiny’

How can I successfully install shiny package from source? Should I go ahead to install all dependencies and dependencies of dependencies first?

解决方案

Shiny has a few package dependencies, and "R CMD INSTALL" won't find them for you, so you need to get them manually. According to the description of shiny, it's dependencies are: 'Rcpp’, ‘httpuv’, ‘mime’, ‘jsonlite’, ‘xtable’, ‘digest’, ‘htmltools’, ‘R6’. So first, get the packages from cran (below are current versions, but they do change over time. Note below is for the computer connected to the internet, you'll need to scp these to the offline computer before continuing):

wget https://cran.r-project.org/src/contrib/Rcpp_0.12.4.tar.gz 
wget https://cran.r-project.org/src/contrib/httpuv_1.3.3.tar.gz 
wget https://cran.r-project.org/src/contrib/mime_0.4.tar.gz 
wget https://cran.r-project.org/src/contrib/jsonlite_0.9.19.tar.gz 
wget https://cran.r-project.org/src/contrib/digest_0.6.9.tar.gz 
wget https://cran.r-project.org/src/contrib/htmltools_0.3.5.tar.gz 
wget https://cran.r-project.org/src/contrib/R6_2.1.2.tar.gz 
wget https://cran.r-project.org/src/contrib/shiny_0.13.2.tar.gz

Then go through them in that same order with R CMD INSTALL. eg:

R CMD INSTALL Rcpp_0.12.4.tar.gz

Once all the dependencies are there, R CMD INSTALL should let you install shiny.

这篇关于如何在离线 Debian 机器上安装 R 包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆