我可以使用以下功能获取所有可用软件包的列表:
ap <- available.packages()
但是如何从R中获得这些软件包的描述,因此我可以得到一个带有两列的
data.frame
:包裹和描述?
最佳答案
我实际上认为您希望将“包”和“标题”作为“描述”运行到几行。所以这是前者,如果您确实想要“Description”,只需将“Description”放在最后一个子集中:
R> ## from http://developer.r-project.org/CRAN/Scripts/depends.R and adapted
R>
R> require("tools")
R>
R> getPackagesWithTitle <- function() {
+ contrib.url(getOption("repos")["CRAN"], "source")
+ description <- sprintf("%s/web/packages/packages.rds",
+ getOption("repos")["CRAN"])
+ con <- if(substring(description, 1L, 7L) == "file://") {
+ file(description, "rb")
+ } else {
+ url(description, "rb")
+ }
+ on.exit(close(con))
+ db <- readRDS(gzcon(con))
+ rownames(db) <- NULL
+
+ db[, c("Package", "Title")]
+ }
R>
R>
R> head(getPackagesWithTitle()) # I shortened one Title here...
Package Title
[1,] "abc" "Tools for Approximate Bayesian Computation (ABC)"
[2,] "abcdeFBA" "ABCDE_FBA: A-Biologist-Can-Do-Everything of Flux ..."
[3,] "abd" "The Analysis of Biological Data"
[4,] "abind" "Combine multi-dimensional arrays"
[5,] "abn" "Data Modelling with Additive Bayesian Networks"
[6,] "AcceptanceSampling" "Creation and evaluation of Acceptance Sampling Plans"
R>
关于r - R中所有CRAN中所有软件包的列表和描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11560865/