从 R 包描述中读取 Authors@R 字段作为向量

标签 r package metadata r-package

如何从 DESCRIPTION 文件中读取 Authors@R 字段作为向量?

> packageDescription("dplyr")$`Authors@R`
[1] "\n    c(person(given = \"Hadley\",\n             family = \"Wickham\",\n             role = c(\"aut\", \"cre\"),\n             email = \"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7e161f1a121b073e0c0d0a0b1a1711501d1113" rel="noreferrer noopener nofollow">[email protected]</a>\",\n             comment = c(ORCID = \"0000-0003-4757-117X\")),\n      person(given = \"Romain\",\n             family = \"François\",\n             role = \"aut\",\n             comment = c(ORCID = \"0000-0002-2444-4226\")),\n      person(given = \"Lionel\",\n             family = \"Henry\",\n             role = \"aut\"),\n      person(given = \"Kirill\",\n             family = \"Müller\",\n             role = \"aut\",\n             comment = c(ORCID = \"0000-0002-1416-3412\")),\n      person(given = \"RStudio\",\n             role = c(\"cph\", \"fnd\")))"

最佳答案

我们可以用eval(parse)包装,因为它返回一个字符串

eval(parse(text = packageDescription("dplyr")$`Authors@R`))

即如果我们检查 cat

cat(packageDescription("dplyr")$`Authors@R`)

    c(person(given = "Hadley",
             family = "Wickham",
             role = c("aut", "cre"),
             email = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="315950555d5448714342454455585e1f525e5c" rel="noreferrer noopener nofollow">[email protected]</a>",
             comment = c(ORCID = "0000-0003-4757-117X")),
      person(given = "Romain",
             family = "François",
             role = "aut",
             comment = c(ORCID = "0000-0002-2444-4226")),
      person(given = "Lionel",
             family = "Henry",
             role = "aut"),
      person(given = "Kirill",
             family = "Müller",
             role = "aut",
             comment = c(ORCID = "0000-0002-1416-3412")),
      person(given = "RStudio",
             role = c("cph", "fnd")))

关于从 R 包描述中读取 Authors@R 字段作为向量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69667175/

相关文章:

r - 如何减少从插入符号传递给 RF 的默认 ntree=500 参数?

r - 使用循环添加顺序值

r - 如何展平列表列表?

package - NuGet 包不将 XMLDoc 文件与 dll 一起复制到 bin

typescript - typescript 属性装饰器可以为类设置元数据吗?

iOS在线广播流媒体问题

r - 从 R 中的热图簇中获取属于每个簇的行名称

laravel - 如何更改 Larecipe v2.0 Laravel 包中的 Logo ?

package - 如何删除 sublime text 2 中的包

macos - 使用 mdls 命令生成元数据报告