在我的工作场所,我们正在为不同版本的 R 安装许多库。所需的大小正在迅速增加。我可以做什么来尽可能减少每次安装?
我知道 --no-docs 并且我需要 --with-keep.source
EDIT:这是对我的设置的快速研究
我将我的图书馆复制到/tmp/library
library(fs)
library(data.table)
library(stringr)
lib_dir <- "/tmp/library"
pkgs <- dir_ls(lib_dir)
dirs <- dir_info(pkgs, recurse = TRUE)[,1:3]
setDT(dirs)
dirs <- dirs[type != "directory"]
# ==> We can see files at the root of each library take 12M in aggreagte <==
dirs[depth == 4, .(size = sum(size))]
# size
# 1: 12M
dirs[, depth := str_count(path, "/")]
dirs[, pkg := file.path(lib_dir, str_match(path, sprintf("%s/(.*?)/.*", lib_dir))[,2L])]
dirs[depth > 4L, pkg_dir := str_match(path, sprintf("%s/(.*?)/.*", pkg))[,2L]]
# ==> The worst offenders are indeed libs, and lib is also large <==
dirs[depth > 4, .(size = sum(size)), pkg_dir][order(-size)][1:10]
# pkg_dir size
# 1: libs 610.77M
# 2: include 144.18M
# 3: doc 140.93M
# 4: lib 104.58M
# 5: R 91.31M
# 6: help 61.78M
# 7: html 51.02M
# 8: data 25.9M
# 9: java 11.74M
# 10: www 8.38M
然后我跑了strip --strip-debug
on libs
and lib
达到以下目的
dirs[depth > 4, .(size = sum(size)), pkg_dir][order(-size)][1:10]
# pkg_dir size
# 1: include 144.18M
# 2: doc 140.93M
# 3: libs 95.24M
# 4: R 91.31M
# 5: help 61.78M
# 6: html 51.02M
# 7: data 25.9M
# 8: java 11.74M
# 9: www 8.38M
# 10: htmlwidgets 8.24M
从上面的例子我有以下问题:docs
似乎有我可以访问的小插曲browseVignettes()
我不需要这个,但我仍然需要help("stuff")
上班。
- 我可以使用以下方法实现这一点吗
--no-docs
or --no-help
(我尝试过,但是运行R CMD INSTALL --no-docs --no-html xtable
仍然生成 pdf 和 html 文件)?
- 我可以在不失去基本功能的情况下保存其他内容吗?