A.14 安装 R 包
Iñaki Ucar 开发的 cran2copr 项目实现在 Fedora 上安装预编译好的二进制 R 包,项目目的类似 Debian 平台上的 cran2deb
devtools 是开发 R 包的常用工具,同时具有很重的依赖,请看
::package_dependencies('devtools', recursive = TRUE) tools
## $devtools ## [1] "usethis" "cli" "desc" "ellipsis" "fs" ## [6] "lifecycle" "memoise" "miniUI" "pkgbuild" "pkgdown" ## [11] "pkgload" "profvis" "rcmdcheck" "remotes" "rlang" ## [16] "roxygen2" "rversions" "sessioninfo" "stats" "testthat" ## [21] "tools" "urlchecker" "utils" "withr" "R6" ## [26] "rprojroot" "methods" "glue" "cachem" "shiny" ## [31] "htmltools" "callr" "crayon" "prettyunits" "processx" ## [36] "bslib" "digest" "downlit" "httr" "jsonlite" ## [41] "magrittr" "purrr" "ragg" "rmarkdown" "tibble" ## [46] "whisker" "xml2" "yaml" "htmlwidgets" "stringr" ## [51] "vctrs" "curl" "xopen" "brew" "commonmark" ## [56] "knitr" "stringi" "cpp11" "brio" "evaluate" ## [61] "praise" "ps" "waldo" "clipr" "gert" ## [66] "gh" "rappdirs" "rstudioapi" "graphics" "grDevices" ## [71] "sass" "jquerylib" "base64enc" "mime" "fastmap" ## [76] "fansi" "askpass" "credentials" "openssl" "sys" ## [81] "zip" "gitcreds" "httr2" "ini" "highr" ## [86] "xfun" "systemfonts" "textshaping" "fontawesome" "tinytex" ## [91] "httpuv" "xtable" "sourcetools" "later" "promises" ## [96] "pillar" "pkgconfig" "diffobj" "rematch2" "Rcpp" ## [101] "utf8"
其中,依赖关系见表 A.2
表 A.2: devtools 的系统依赖 curl git2r openssl Ubuntu libcurl-dev49 libgit2-dev libssl-dev CentOS libcurl-devel libgit2-devel openssl-devel
sf 是处理空间数据的常用工具
::package_dependencies('sf', recursive = TRUE) tools
## $sf ## [1] "methods" "classInt" "DBI" "graphics" "grDevices" ## [6] "grid" "magrittr" "Rcpp" "s2" "stats" ## [11] "tools" "units" "utils" "e1071" "class" ## [16] "KernSmooth" "wk" "MASS" "proxy"
其主要的系统依赖分别是 GEOS 3.5.1, GDAL 2.2.2, PROJ 4.9.2
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable sudo apt-get update sudo apt-get install -y libudunits2-dev libgdal-dev libgeos-dev libproj-dev
这样也同时解决了 udunits2、 rgdal 和 rgeos 等 3个 R 包的系统依赖,其中 udunits2 使用如下命令安装
install.packages(’udunits2’, configure.args = '--with-udunits2-include=/usr/include/udunits2')
图形设备支持 cairo png jpeg tiff
sudo apt-get install -y libcairo2-dev libjpeg-dev libpng-dev libtiff-dev
-
sudo yum install fftw-devel # CentOS sudo apt-get install libfftw3-dev # Ubuntu
在 Ubuntu 系统上安装最新的 libmagick++-dev 库
sudo add-apt-repository -y ppa:opencpu/imagemagick sudo apt-get update sudo apt-get install -y libmagick++-dev
在 CentOS 系统上
sudo yum install -y ImageMagick-c++-devel
然后安装 R 包
install.packages(c('imager', 'magick'))
rgl 是绘制真三维图形的重量级 R 包
sudo apt-get install libcgal-dev libglu1-mesa-dev libx11-dev # Ubuntu sudo yum install mesa-libGLU mesa-libGLU-devel # CentOS
然后安装 R 包
install.packages('rgl')
在 Ubuntu 系统上还可以这样安装
sudo add-apt-repository ppa:marutter/rrutter3.5 sudo apt-get update sudo apt-get install r-cran-rgl
rJava 是 Java 语言和 R 语言之间实现通信交流的桥梁
sudo apt-get install -y default-jdk sudo R CMD javareconf
然后安装 rJava 包
install.packages(’rJava’)
igraph 是网络数据分析的必备 R 包,为了发挥其最大性能,需要安装三个系统依赖
sudo apt-get install -y libgmp-dev libxml2-dev libglpk-dev
然后安装 R 包
install.packages('igraph')
gpuR 是基于 GPU 进行矩阵计算的扩展包,依赖 RcppEigen 确保安装 OpenCL 和 RViennaCL 或者 安装 Nvidia 驱动和 CUDA,使用 gpuRcuda 和 gputools 扩展包,下面安装指导来自其 Wiki
# Install OpenCL headers sudo apt-get install opencl-headers opencv-dev # Install NVIDIA Drivers and CUDA sudo add-apt-repository -y ppa:xorg-edgers/ppa sudo apt-get update sudo apt-get install nvidia-346 nvidia-settings
nloptr 是 NLopt 的 R 语言接口,首先安装 NLopt 程序库
sudo apt-get install libnlopt-dev
然后安装 R 包install.packages('nloptr')
,nloptr 被 700+ R 包依赖,如 lme4, spaMM, glmmTMB, rstanarm 等。Rmpfr
sudo apt-get install libmpfr-dev
install.packages(’Rmpfr’)
geojson
sudo yum install jq-devel protobuf-devel
install.packages(c('geojson','geojsonio','jqr','protolite'))
lgcp
sudo yum install bwidget
install.packages(c('rpanel','lgcp'))
ijtiff
sudo yum install jbigkit-devel
install.packages('ijtiff')
webshot 包用于截图
sudo apt install phantomjs
install.packages(’webshot’)
gifski 包合成 GIF 动图
sudo apt-get install cargo
install.packages('gifski')
libcurl-dev 是一个虚包 virtual package,由 libcurl4-openssl-dev 或 libcurl4-nss-dev 或 libcurl4-gnutls-dev 实际提供,选择其中一个安装即可。↩︎