Home > Mobile >  Read Authors@R field from DESCRIPTION of R package as vector
Read Authors@R field from DESCRIPTION of R package as vector

Time:10-22

How can I read Authors@R field from DESCRIPTION file as vector?

> packageDescription("dplyr")$`Authors@R`
[1] "\n    c(person(given = \"Hadley\",\n             family = \"Wickham\",\n             role = c(\"aut\", \"cre\"),\n             email = \"[email protected]\",\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\")))"

CodePudding user response:

We may wrap with eval(parse as it returns a string

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

i.e. if we check with cat

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

    c(person(given = "Hadley",
             family = "Wickham",
             role = c("aut", "cre"),
             email = "[email protected]",
             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")))
  • Related