How to find out which package version is loaded in R?

前端 未结 12 1577
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 14:32

I am in a process of figuring out how to use my university cluster. It has 2 versions of R installed. System wide R 2.11 (Debian 6.0) and R 2.14.2 in non-standard location.

相关标签:
12条回答
  • 2020-11-29 14:53

    Use the R method packageDescription to get the installed package description and for version just use $Version as:

    packageDescription("AppliedPredictiveModeling")$Version
    [1] "1.1-6"
    
    0 讨论(0)
  • 2020-11-29 14:56

    You can use sessionInfo() to accomplish that.

    > 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’

    Or:

    "Rmpi" %in% loadedNamespaces()
    
    0 讨论(0)
  • 2020-11-29 14:56

    You can use packageVersion to see what version of a package is loaded

    > 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

    0 讨论(0)
  • 2020-11-29 14:57

    Search() can give a more simplified list of the attached packages in a session (i.e., without the detailed info given by sessionInfo())

    search {base}- R Documentation
    Description: Gives a list of attached packages. Search()

    search()
    #[1] ".GlobalEnv"        "package:Rfacebook" "package:httpuv"   
    #"package:rjson"    
    #[5] "package:httr"      "package:bindrcpp"  "package:forcats"   # 
    #"package:stringr"  
    #[9] "package:dplyr"     "package:purrr"     "package:readr"     
    #"package:tidyr"    
    #[13] "package:tibble"    "package:ggplot2"   "package:tidyverse" 
    #"tools:rstudio"    
    #[17] "package:stats"     "package:graphics"  "package:grDevices" 
    #"package:utils"    
    #[21] "package:datasets"  "package:methods"   "Autoloads"         
    #"package:base"
    
    0 讨论(0)
  • 2020-11-29 14:58

    To check the version of R execute : R --version

    Or after you are in the R shell print the contents of version$version.string

    EDIT

    To check the version of installed packages do the following.

    After loading the library, you can execute 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.

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

    The above will print the versions of the RANN library and the graphics library.

    0 讨论(0)
  • 2020-11-29 15:06

    Simply use help(package="my_package") and look at the version shown.

    This assumes there are no other package versions in the same .libPaths.

    0 讨论(0)
提交回复
热议问题