Question

I am trying to create a package with devtools. I want to set a few options so that the DESCRIPTION file is auto-populated. I can't seem to get it right.

This is a problem that can be easily fixed manually, I think, but I want this to work in code. Worried the error will affect me later. Any suggestions on appropriate syntax? I have my functions in a folder called "R". I set my working directory to the parent folder for R. Then:

library(devtools)

install_github("devtools")

options(devtools.desc.author="First Last <first.last@example.com> [aut, cre]")

options(devtools.desc.license="GPL-3")

load_all()

This outputs this:

No DESCRIPTION found. Creating default:

Package: mypackage
Title: 
Description: 
Version: 0.1
Authors@R: First Last <first.last@example.com> [aut, cre]
Depends: R (>= 3.0.1)
License: GPL-3
LazyData: true
Loading mypackage
Invalid DESCRIPTION:
Malformed Authors@R field:
 <text>:1:7: unexpected symbol
1: First Last
         ^

Required fields missing:
  Author Maintainer

See the information on DESCRIPTION files in section 'Creating R packages' of the 'Writing R Extensions' manual.

I am aware that in some way the Authors@R field can/is in some way replacing the Maintainer field, but wondering how to get this to stop throwing errors, and what they mean.

Thanks in advance!

Was it helpful?

Solution

Unfortunately you need:

options(devtools.desc.author="'First Last <first.last@example.com> [aut, cre]'")

because the contents of Authors@R must be a valid R expression.

Or using the person function from the utils package:

authors_at_r <- paste0(
  "'", 
  person(
    "First", 
    "Last", 
    email = "first.last@example.com", 
    role  = c("aut", "cre")), 
  "'"
)
options(devtools.desc.author=authors)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top