- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经获得了一堆软件包及其依赖项的源文件,我想将它们安装在无法访问互联网的计算机上。我想使用 USB 内存棒将所有这些安装在其他计算机上,但某些软件包的安装失败,因为依赖项没有在软件包之前安装。如何在需要它们的包之前按顺序安装依赖项?
这是我当前获取包及其依赖项并按正确顺序获取它们的方法:
# find the dependencies for the packages I want
# from http://stackoverflow.com/a/15650828/1036500
getPackages <- function(packs){
packages <- unlist(
tools::package_dependencies(packs, available.packages(),
which=c("Depends", "Imports"), recursive=TRUE)
)
packages <- union(packages, packs)
packages
}
# packages I want
my_packages <- c('stringr', 'devtools', 'ggplot2', 'dplyr', 'tidyr', 'rmarkdown', 'knitr', 'reshape2', 'gdata')
# get names of dependencies and try to get them in the right order, this seems ridiculous...
my_packages_and_dependencies <- getPackages(my_packages)
dependencies_only <- setdiff(my_packages_and_dependencies, my_packages)
deps_of_deps <- getPackages(dependencies_only)
deps_of_deps_of_deps <- getPackages(deps_of_deps)
my_packages_and_dependencies <- unique(c(deps_of_deps_of_deps, deps_of_deps, dependencies_only, my_packages))
# where to keep the source?
local_CRAN <- paste0(getwd(), "/local_CRAN")
# get them from CRAN, source files
download.packages(pkgs = my_packages_and_dependencies, destdir = local_CRAN, type = "source")
# note that 'tools', 'methods', 'utils, 'stats', etc. art not on CRAN, but are part of base
# from http://stackoverflow.com/a/10841614/1036500
library(tools)
write_PACKAGES(local_CRAN)
现在假设我在另一台计算机上全新安装了 R 和 RStudio(以及 Rtools 或 Xcode)并且没有互联网连接,我插入 USB 内存棒,打开 RProj 文件以设置工作目录,然后运行此命令脚本:
#############################################################
## Install from source (Windows/OSX/Linux)
# What do I want to install?
my_packages_and_dependencies <- c("methods", "tools", "bitops", "stats", "colorspace", "graphics",
"tcltk", "Rcpp", "digest", "jsonlite", "mime", "RCurl", "R6",
"stringr", "brew", "grid", "RColorBrewer", "dichromat", "munsell",
"plyr", "labeling", "grDevices", "utils", "httr", "memoise",
"whisker", "evaluate", "rstudioapi", "roxygen2", "gtable", "scales",
"proto", "MASS", "assertthat", "magrittr", "lazyeval", "DBI",
"stringi", "yaml", "htmltools", "caTools", "formatR", "highr",
"markdown", "gtools", "devtools", "ggplot2", "dplyr", "tidyr",
"rmarkdown", "knitr", "reshape2", "gdata")
# where are the source files?
local_CRAN <- paste0(getwd(), "/local_CRAN")
# scan all packages and get files names of wanted source pckgs
# I've got other things in this dir also
wanted_package_source_filenames <- list.files(local_CRAN, pattern = "tar.gz", full.names = TRUE)
# put them in order to make sure deps go first, room for improvement here...
trims <- c(local_CRAN, "/", "tar.gz")
x1 <- gsub(paste(trims, collapse = "|"), "", wanted_package_source_filenames)
x2 <- sapply( strsplit(x1, "_"), "[[", 1)
idx <- match(my_packages_and_dependencies, x2)
wanted_package_source_filenames <- na.omit(wanted_package_source_filenames[idx])
install.packages(wanted_package_source_filenames,
repos = NULL,
dependencies = TRUE,
contrib.url = local_CRAN, # I thought this would take care of getting dependencies automatically...
type = "source" )
这工作得相当好,但仍然有一些软件包无法安装:
sapply(my_packages_and_dependencies, require, character.only = TRUE)
methods tools bitops stats
TRUE TRUE TRUE TRUE
colorspace graphics tcltk Rcpp
TRUE TRUE TRUE TRUE
digest jsonlite mime RCurl
TRUE TRUE TRUE FALSE
R6 stringr brew grid
TRUE TRUE TRUE TRUE
RColorBrewer dichromat munsell plyr
TRUE TRUE TRUE TRUE
labeling grDevices utils httr
TRUE TRUE TRUE FALSE
memoise whisker evaluate rstudioapi
TRUE TRUE TRUE TRUE
roxygen2 gtable scales proto
TRUE TRUE TRUE TRUE
MASS assertthat magrittr lazyeval
TRUE TRUE TRUE TRUE
DBI stringi yaml htmltools
TRUE TRUE TRUE TRUE
caTools formatR highr markdown
TRUE TRUE TRUE TRUE
gtools devtools ggplot2 dplyr
TRUE FALSE FALSE TRUE
tidyr rmarkdown knitr reshape2
FALSE FALSE TRUE TRUE
gdata
TRUE
Warning messages:
1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘RCurl’
2: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘httr’
3: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘devtools’
4: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘ggplot2’
5: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘tidyr’
6: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘rmarkdown’
似乎 knitr 必须出现在 rmarkdown 之前,reshape2 必须出现在 tidyr 和 ggplot2 之前,等等。
必须有一个更简单、更完整的解决方案来解决按非常特定的顺序获取源文件列表的问题,并将所有依赖项按正确的顺序放置。最简单的方法是什么(不使用任何贡献的包)?
这是我当前正在使用的系统,我正在使用软件包的源版本,试图为离线计算机(OSX/Linux/Windows)做好准备:
> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] tcltk grid tools stats graphics
[6] grDevices utils datasets methods base
other attached packages:
[1] gdata_2.13.3 reshape2_1.4.1
[3] knitr_1.9 dplyr_0.4.1
[5] gtools_3.4.1 markdown_0.7.4
[7] highr_0.4 formatR_1.0
[9] caTools_1.17.1 htmltools_0.2.6
[11] yaml_2.1.13 stringi_0.4-1
[13] DBI_0.3.1 lazyeval_0.1.10
[15] magrittr_1.5 assertthat_0.1
[17] proto_0.3-10 scales_0.2.4
[19] gtable_0.1.2 roxygen2_4.1.0
[21] rstudioapi_0.2 evaluate_0.5.5
[23] whisker_0.3-2 memoise_0.2.1
[25] labeling_0.3 plyr_1.8.1
[27] munsell_0.4.2 dichromat_2.0-0
[29] RColorBrewer_1.1-2 brew_1.0-6
[31] stringr_0.6.2 R6_2.0.1
[33] mime_0.2 jsonlite_0.9.14
[35] digest_0.6.8 Rcpp_0.11.4
[37] colorspace_1.2-5 bitops_1.0-6
[39] MASS_7.3-35
loaded via a namespace (and not attached):
[1] parallel_3.1.2
编辑按照Andrie的有用评论,我尝试了miniCRAN,小插图中缺少的一点是如何实际从本地存储库安装软件包。这是我尝试过的:
library("miniCRAN")
# Specify list of packages to download
pkgs <- c('stringr', 'devtools', 'ggplot2', 'dplyr', 'tidyr', 'rmarkdown', 'knitr', 'reshape2', 'gdata')
# Make list of package URLs
revolution <- c(CRAN="http://cran.revolutionanalytics.com")
pkgList <- pkgDep(pkgs, repos=revolution, type="source" )
pkgList
# Set location to store source files
local_CRAN <- paste0(getwd(), "/local_CRAN")
# Make repo for source
makeRepo(pkgList, path = local_CRAN, repos = revolution, type = "source")
# install...
install.packages(pkgs,
repos = local_CRAN, # do I really need "file:///"?
dependencies = TRUE,
contrib.url = local_CRAN,
type = "source" )
结果是:
Installing packages into ‘C:/emacs/R/win-library/3.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository C:/Users/.../local_CRAN/src/contrib
Warning in install.packages :
packages ‘stringr’, ‘devtools’, ‘ggplot2’, ‘dplyr’, ‘tidyr’, ‘rmarkdown’, ‘knitr’, ‘reshape2’, ‘gdata’ are not available (for R version 3.1.2)
我在这里缺少什么?
编辑是的,我错过了file:///
的正确使用,它应该是这样的:
install.packages(pkgs,
repos = paste0("file:///", local_CRAN),
type = "source")
这让我深受感动,现在一切基本上都按预期工作了。非常感谢。现在我只需查看以下内容: fatal error :curl/curl.h:没有这样的文件或目录
,这会阻止 RCurl 和 httr 安装。
最佳答案
包 miniCRAN
可以帮助解决这个问题。您告诉 miniCRAN
您想要安装的软件包列表,然后它会找出依赖关系,下载这些软件包并在您的本地计算机上创建一个行为类似于 CRAN 的存储库,即它尊重 install.packages()
等
更多信息:
阅读vignette
我们正在积极开发 miniCRAN
。跟踪进度并在 github miniCRAN repository 查找最新的开发版本
请参阅 project wiki获取演示文稿、博客文章等的链接
要从本地 miniCRAN
存储库安装,您有两种选择。
首先,您可以使用 URI 约定 file:///
。例如
install.packages("ggplot2", repos="file:///path/to/file/")
或者,您可以将目标配置为 HTTP 服务器,并通过 URL 使您的存储库可用。在这种情况下,您的本地存储库的外观和感觉与 CRAN 镜像完全相同,只是它只包含您想要的包。
关于r - 离线安装包列表: getting dependencies in order,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28885349/
我知道使用 GET 和 SET 函数的公共(public)变量的缺点/私有(private)变量的优点,但目前我正在使用 Ogre3D 开发自己的第一个“真实”游戏(C++)..同时,我有时需要 6-
我正在开发一个 GSM/GPRS 应用程序,它将每 10 秒报告一些值。我必须使用的 SIM 卡每月只有 15MB 可用数据。我使用的是 SIM900 GSM 芯片供您引用。 我到达服务器的方式是通过
这三者有什么区别:gets - 它获取带有 '\n' 的行gets.chomp - 它得到一行,但删除 '\n' 这样对吗? gets.chomp! 怎么样? 最佳答案 gets - 它得到一个末尾带
问题和我现在遇到的问题 脚本 顺便说一句,评论是挪威语的,如果它们看起来很奇怪哈哈 Connect-AzureAD #variabel $Users = Get-AzureADUser -All:$t
我现在面临的问题是获取一个 URL,如下所示: www.example.com/example.php?url=www.google.com 现在的问题是,如果我的网址中有一个 get,如下所示: w
我有一个 queryString 传递给 servlet 的 doGet() 方法,如下所示: count=9&preId0=-99&objId0=-99&preId1=-99&objId1=-99&
这是我在 Django 模板中的代码: {% for tag in tags %} {{ tag }} {% endfor %} 在view.py中: def tag_find(
我正在尝试在express.js中为我的网络应用程序创建一个路由系统,我需要知道是否需要使用app.get/post/put/delete.apply以编程方式设置多个功能对于一条路线。 也是如此 a
我正在通过示例查看 A.Mele Django,第 1 章 def post_list(request, category=None): object_list = Post.publishe
如果我想找到与IIS站点或应用程序关联的目录,我该怎么做? 我似乎无法从Get-Website和Get-WebApplication的对象的任何属性中找到任何允许我这样做的东西。 最佳答案 只需查看一
不知道发生了什么。当我执行以下代码时......它运行良好......但它产生了错误。如果我将以下内容粘贴到我的浏览器地址栏中并点击它,我会得到一个 URL。如果我通过 KRL http:get 输入
Curl 提供了一系列不同的带有 X 前缀的 http 方法调用,但也提供了不带 X 的相同方法。我两种都试过了,但我似乎无法弄清楚其中的区别。有人可以快速向我解释这两种操作有何不同吗? 最佳答案 默
request.GET.get 是什么意思?我在 Django 中看到类似的东西 page = request.GET.get('page', 1) 我认为它与类似的东西有关 « 它们是如
我正在从我的 Angular2 站点查询一些 Elasticsearch 服务器。为了帮助提高安全性,我们希望锁定对 GET 请求的访问权限。 Elasticsearch 支持带主体的 GET,但我在
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 4年前关闭。 Improve t
调用 HTable.get(List) 返回的 Result 数组的顺序是什么? ? 我的意思是,假设与输入列表的顺序相同是否正确? 最佳答案 结果数组中的顺序将与输入列表的顺序相同。与批处理方法一样
所以我有一个看起来像这样的 JSON 数组: var myData = { foo : { biz : 'baz', fig : 'tree' } }
我正在学习 Ajax、javascript 和 html,并且有一个应用程序可以触发“get”请求,然后再触发另一个“get”请求。这些请求是用户按下按钮的结果。在我的 servlet 中,我使用 T
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 6 年前。 Improv
运行以下 cmdlet 适用于组成员(Amer 域中的组)中的所有用户,无论列出的用户位于哪个域: Get-ADGroupMember -Server amer 但是,当尝试通过管道传输到 Get-
我是一名优秀的程序员,十分优秀!