本文翻译自:How to find out which package version is loaded in R?

I am in a process of figuring out how to use my university cluster. 我正在弄清楚如何使用我的大学集群。 It has 2 versions of R installed. 它安装了2个版本的R. System wide R 2.11 (Debian 6.0) and R 2.14.2 in non-standard location. 系统范围的R 2.11(Debian 6.0)和R 2.14.2在非标准位置。

I am trying to use MPI together with snow. 我正在尝试将MPI与雪一起使用。 The code I am trying to run is the following 我试图运行的代码如下

library(snow)
library(Rmpi)
cl <- makeMPIcluster(mpi.universe.size()-1)
stopCluster(cl)
mpi.quit()

It works without the problems on R 2.11. 它在R 2.11上没有问题。 (I launch the script with mpirun -H localhost,n1,n2,n3,n4 -n 1 R --slave -f code.R ). (我用mpirun -H localhost,n1,n2,n3,n4 -n 1 R --slave -f code.R )。 Now when I try to do it with R 2.14.2, I get the following message: 现在,当我尝试使用R 2.14.2时,我收到以下消息:

Error: This is R 2.11.1, package 'snow' needs >= 2.12.1
In addition: Warning message:

So it seems that R loads the package snow version compiled for R 2.11. 所以似乎R加载为R 2.11编译的包雪版本。 I've installed snow under R 2.14 into my home folder and I added the following lines to my code: 我已将R 2.14下的雪安装到我的主文件夹中,并在代码中添加了以下行:

.libPaths("/soft/R/lib/R/library")
.libPaths("~/R/x86_64-pc-linux-gnu-library/2.11")
print(.libPaths())
print(sessionInfo())
print(version)

And the output before the error confirms that I am indeed running R 2.14.2 and my R packages folder is first in search path. 并且错误之前的输出确认我确实正在运行R 2.14.2并且我的R packages文件夹首先在搜索路径中。 But I still get the error. 但我仍然得到错误。

So my question is how do I determine which version of package is loaded in R? 所以我的问题是如何确定在R中加载哪个版本的软件包? I can see with installed.packages all the packages which are installed, so maybe there is some function which lists similar information for loaded packages? 我可以在installed.packages中看到所有installed.packages的软件包,所以可能有一些函数列出了加载软件包的类似信息?


#1楼

参考:https://stackoom.com/question/kaRh/如何找出R中加载的软件包版本


#2楼

You can use sessionInfo() to accomplish that. 您可以使用sessionInfo()来完成此任务。

> sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-linux-gnu (64-bit)locale:[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=C                 LC_NAME=C                 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       attached base packages:
[1] graphics  grDevices utils     datasets  stats     grid      methods   base     other attached packages:
[1] ggplot2_0.9.0  reshape2_1.2.1 plyr_1.7.1    loaded via a namespace (and not attached):[1] colorspace_1.1-1   dichromat_1.2-4    digest_0.5.2       MASS_7.3-18        memoise_0.1        munsell_0.3       [7] proto_0.3-9.2      RColorBrewer_1.0-5 scales_0.2.0       stringr_0.6
>

However, as per comments and the answer below, there are better options 但是,根据评论和下面的答案,有更好的选择

> packageVersion("snow")

[1] '0.3.9' [1]'0.3.9'

Or: 要么:

"Rmpi" %in% loadedNamespaces()

#3楼

To check the version of R execute : R --version 检查R执行的版本: R --version

Or after you are in the R shell print the contents of version$version.string 或者在你进入R shell后打印version$version.string的内容

EDIT 编辑

To check the version of installed packages do the following. 要检查已安装软件包的版本,请执行以下操作。

After loading the library, you can execute sessionInfo () 加载库后,您可以执行sessionInfo ()

But to know the list of all installed packages: 但要知道所有已安装软件包的列表:

packinfo <- installed.packages(fields = c("Package", "Version"))
packinfo[,c("Package", "Version")]

OR to extract a specific library version, once you have extracted the information using the installed.package function as above just use the name of the package in the first dimension of the matrix. 或者要提取特定的库版本,一旦使用上面的installed.package函数提取信息,只需在矩阵的第一维中使用包的名称。

packinfo["RANN",c("Package", "Version")]
packinfo["graphics",c("Package", "Version")]

The above will print the versions of the RANN library and the graphics library. 以上将打印RANN库和图形库的版本。


#4楼

You can use packageVersion to see what version of a package is loaded 您可以使用packageVersion来查看加载了哪个版本的包

> packageVersion("snow")
[1] ‘0.3.9’

Although it sounds like you want to see what version of R you are running, in which case @Justin's sessionInfo suggestion is the way to go 虽然听起来你想看看你正在运行什么版本的R,但在这种情况下@ Justin的sessionInfo建议是要走的路


#5楼

你可以尝试这样的事情:

  1. package_version(R.version)

  2. getRversion()


#6楼

使用以下代码获取系统中安装的R软件包的版本:

installed.packages(fields = c ("Package", "Version"))

如何找出R中加载的软件包版本?相关推荐

  1. 使用Win10系统在R中加载TensorFlow-gup加快深度学习运行之攻略

    弗朗索瓦.肖莱著<深度学习R语言版>说,用CUP进行深度学习运算可能需要数小时,但用GPU可能只要几分钟.不过,该书只叙述了在Ubuntu下安装GUP的方法,不推荐Windows下使用Te ...

  2. 在layui layer 弹出层中加载 layui table

    1 layui.use('table', function(){ 2 var table = layui.table; 3 layer.open({ 4 type : 1, 5 area : [ &q ...

  3. python调用r语言加载包错误_Python中调用R语言包指南.docx

    Python中调用R语言包指南R语言是非常强大的做统计分析和建模方面的开源软件,它有非常丰富的统计软件包,做统计可以说只有你想不到的,没有R办不到的.Python又是当下最流行的编程软件之一,Pyth ...

  4. 《R数据可视化手册》一1.4 从Excel文件中加载数据

    本节书摘来自异步社区<R数据可视化手册>一书中的第1章,第1.4节,作者 [美]Winston Chang,更多章节内容可以访问云栖社区"异步社区"公众号查看 1.4 ...

  5. 从内存中加载并启动一个exe

    从内存中加载并启动一个exe 文章作者:Idle_ (阿呆) 信息来源:[url]http://cnxhacker.net/article/show/2821.html[/url] windows似乎 ...

  6. 微策略2011校园招聘笔试题(找出数组中两个只出现一次的数字)

    1.8*8的棋盘上面放着64个不同价值的礼物,每个小的棋盘上面放置一个礼物(礼物的价值大于0),一个人初始位置在棋盘的左上角,每次他只能向下或向右移动一步,并拿走对应棋盘上的礼物,结束位置在棋盘的右下 ...

  7. 从内存中加载并运行exe(两种方法)

    windows似乎只提供了一种启动进程的方法:即必须从一个可执行文件中加载并启动.      而下面这段代码就是提供一种可以直接从内存中启动一个exe的变通办法.      用途嘛,     也许可以 ...

  8. springboot 读取配置文件_使用 @ConfigurationProperties 在 Spring Boot 中加载配置

    本文地址: 使用 @ConfigurationProperties 在 Spring Boot 中加载配置 使用 Spring Boot 加载配置文件的配置非常便利,我们只需要使用一些注解配置一下就能 ...

  9. 从源代码中加载res / values / dimension.xml中的维度值

    本文翻译自:Load dimension value from res/values/dimension.xml from source code I'd like to load the value ...

最新文章

  1. linux I/O--五种I/O模型(一)
  2. linux中三个time:atime、mtime、ctime
  3. android object数组赋值_VUE2.X为什么只对数组的部分方法实现了数据监测?
  4. allegro下快捷键设置[转贴]
  5. innodb doublewrite
  6. 马云:遇见好老板很重要;锤子上海法人变更;摩拜更名美团单车 | 极客头条...
  7. php7 xmlreader,PHP扩展之XML操作(四)——XMLReader
  8. FPGA 38译码器
  9. java根据模板导出word poi-tl使用Word模板和数据创建Word文档
  10. linux中tailf命令详解,linux tailf命令详解
  11. [方便WAP网站开发]在线手机WAP模拟器或软件
  12. 如果GOOGLE退出中国,我们怎么办???
  13. 海外看病大火,盛诺一家获中信里昂千万美金级C轮融资
  14. vue中el-radio-group点击事件,双击取消
  15. 苹果充电时一充一停怎么办_苹果充电线一会儿能充一会儿不能充怎么回事
  16. 三国杀开源系列之三106@365
  17. 论文阅读 - 《Exposing DeepFake Videos By Detecting Face Warping Artifacts》
  18. UTC,GPS Time和TAI
  19. CentOS 7.4.1708(Core) 内核升级攻略
  20. html怎么设置过渡字体,web前端入门到实战:css3基础-文本与字体+转换+过渡+动画+案例...

热门文章

  1. 为什么很多程序员面试造火箭,入职拧螺丝?
  2. Android 打印方法调用堆栈
  3. Java Thread.join()详解
  4. nginx配置文件基本配置
  5. Jazzy 文档生成器使用
  6. uniapp处理IOS底部横条安全区域
  7. 【BZOJ】1823: [JSOI2010]满汉全席(2-sat)
  8. C语言博客作业--数据类型
  9. iOS开发笔记 -- 推送证书的创建及合并
  10. requests从api中获取数据并存放到mysql中