devtools描述文件

for*_*per 13 r devtools package

我正在尝试使用devtools创建一个包.我想设置几个选项,以便自动填充DESCRIPTION文件.我似乎无法做对.

我认为这是一个可以轻松手动修复的问题,但我希望这可以在代码中使用.担心错误会影响我以后.关于适当语法的任何建议?我的功能在一个名为"R"的文件夹中.我将我的工作目录设置为R的父文件夹.然后:

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()
Run Code Online (Sandbox Code Playgroud)

这输出:

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.
Run Code Online (Sandbox Code Playgroud)

我知道在某种程度上,Authors @ R字段可以/在某种程度上取代Maintainer字段,但想知道如何让它停止抛出错误,以及它们的含义.

提前致谢!

had*_*ley 14

不幸的是你需要:

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

因为内容Authors@R必须是有效的R表达式.

或者使用包中的person功能utils:

authors_at_r <- paste0(
  "'", 
  person(
    "First", 
    "Last", 
    email = "first.last@example.com", 
    role  = c("aut", "cre")), 
  "'"
)
options(devtools.desc.author=authors)
Run Code Online (Sandbox Code Playgroud)