如何检查 r 中加载的包版本


您可以使用以下函数来检查 R 中加载了哪个包版本:

 #display package version
packageVersion(" ggplot2 ")

#display the date when this package version was released
packageDate(" ggplot2 ")

#display description of the package
packageDescription(" ggplot2 ")

下面的例子展示了如何在实践中使用这些函数。

示例:检查 R 中加载了哪个包版本

假设我们将ggplot2包加载到当前的 R 环境中:

 library (ggplot2)

我们可以使用packageVersion()函数来检查加载了哪个版本的 ggplot2:

 #display package version
packageVersion(" ggplot2 ")

[1] '3.3.2'

我们看到版本3.2.2已加载。

要查明此版本的发布时间,您可以使用packageDate()函数:

 #display the date when this package version was released
packageDate(" ggplot2 ")

[1] "2020-06-17"

我们可以看到这个版本是在2020年6月17日发布的。

要显示包的描述,我们可以使用packageDescription()函数:

 #display description of the package
packageDescription(" ggplot2 ")

Package: ggplot2
Version: 3.3.2
Title: Create Elegant Data Visualizations Using the Grammar of Graphics
Description: A system for 'declaratively' creating graphics, based on
        "The Grammar of Graphics". You provide the data, tell 'ggplot2'
        how to map variables to aesthetics, what graphical primitives
        to use, and it takes care of the details.
Authors@R: c( person("Hadley", "Wickham", , "hadley@rstudio.com",
        "aut", comment = c(ORCID = "0000-0003-4757-117X"),
        person("Winston", "Chang", , role = "aut", comment = c(ORCID =
        "0000-0002-1576-2126"), person("Lionel", "Henry", , role =
        "aut"), person("Thomas Lin", "Pedersen", ,
        "thomas.pedersen@rstudio.com", role = c("aut", "cre"), comment
        = c(ORCID = "0000-0002-5147-4711"), person("Kohske",
        "Takahashi", role = "aut"), person("Claus", "Wilke", role =
        "aut", comment = c(ORCID = "0000-0002-7470-9261"),
        person("Kara", "Woo", role = "aut", comment = c(ORCID =
        "0000-0002-5125-4188"), person("Hiroaki", "Yutani", role =
        "aut", comment = c(ORCID = "0000-0002-3385-7233"),
        person("Dewey", "Dunnington", role = "aut", comment = c(ORCID =
        "0000-0002-9415-4582"), person("RStudio", role = c("cph",
        "fnd")))
Depends: R (>= 3.2)
Imports: digest, glue, grDevices, grid, gtable (>= 0.1.1), isoband,
        MASS, mgcv, rlang (>= 0.3.0), scales (>= 0.5.0), stats, tibble,
        withr (>= 2.0.0)
Suggested: covr, dplyr, ggplot2movies, hexbin, Hmisc, knitr, lattice,
        mapproj, maps, maptools, multcomp, munsell, nlme, profvis,
        quantreg, RColorBrewer, rgeos, rmarkdown, rpart, sf (>= 0.7-3),
        svglite (>= 1.2.0.9001), testthat (>= 2.1.0), vdiffr (>= 0.3.0)
Enhances:sp
License: GPL-2 | LICENSE file
URL: https://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2
BugReports: https://github.com/tidyverse/ggplot2/issues
LazyData: true
Collate: 'ggproto.r' 'ggplot-global.R' 'aaa-.r'
        'aes-color-fill-alpha.r' .....
ThumbnailBuilder: knitr
Roxygen Note: 7.1.0.9000
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2020-06-17 06:03:58 UTC; thomas
Author: Hadley Wickham [aut] (<https://orcid.org/0000-0003-4757-117X>),
        Winston Chang [aut] (<https://orcid.org/0000-0002-1576-2126>),
        Lionel Henry [aut], Thomas Lin Pedersen [aut, cre]
        (<https://orcid.org/0000-0002-5147-4711>), Kohske Takahashi
        [aut], Claus Wilke [aut]
        (<https://orcid.org/0000-0002-7470-9261>), Kara Woo [aut]
        (<https://orcid.org/0000-0002-5125-4188>), Hiroaki Yutani [aut]
        (<https://orcid.org/0000-0002-3385-7233>), Dewey Dunnington
        [aut] (<https://orcid.org/0000-0002-9415-4582>), RStudio [cph,
        fnd]
Maintainer: Thomas Lin Pedersen <thomas.pedersen@rstudio.com>
Repository: CRAN
Date/Publication: 2020-06-19 13:00:03 UTC
Built: R 4.0.3; ; 2020-11-20 18:07:33 UTC; unix

-- File: /usr/lib/R/site-library/ggplot2/Meta/package.rds

描述包括对包的用途、包的创建者、报告错误的位置、发布时间等的简要说明。

其他资源

以下教程解释了如何在 R 中执行其他常见任务:

如何清除R中的环境
R中如何检查文件是否存在
如何在 R 中使用 setwd/getwd

添加评论

您的电子邮箱地址不会被公开。 必填项已用*标注