从 DESCRIPTION of R package as vector 中读取 Authors@R 字段
Read Authors@R field from DESCRIPTION of R package as vector
如何从 DESCRIPTION
文件中读取 Authors@R
字段作为向量?
> packageDescription("dplyr")$`Authors@R`
[1] "\n c(person(given = \"Hadley\",\n family = \"Wickham\",\n role = c(\"aut\", \"cre\"),\n email = \"hadley@rstudio.com\",\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
包裹起来,因为它 returns 是一个字符串
eval(parse(text = packageDescription("dplyr")$`Authors@R`))
即如果我们检查 cat
cat(packageDescription("dplyr")$`Authors@R`)
c(person(given = "Hadley",
family = "Wickham",
role = c("aut", "cre"),
email = "hadley@rstudio.com",
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")))
如何从 DESCRIPTION
文件中读取 Authors@R
字段作为向量?
> packageDescription("dplyr")$`Authors@R`
[1] "\n c(person(given = \"Hadley\",\n family = \"Wickham\",\n role = c(\"aut\", \"cre\"),\n email = \"hadley@rstudio.com\",\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
包裹起来,因为它 returns 是一个字符串
eval(parse(text = packageDescription("dplyr")$`Authors@R`))
即如果我们检查 cat
cat(packageDescription("dplyr")$`Authors@R`)
c(person(given = "Hadley",
family = "Wickham",
role = c("aut", "cre"),
email = "hadley@rstudio.com",
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")))