Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

devtools DESCRIPTION file

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 <[email protected]> [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 <[email protected]> [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!

like image 558
forlooper Avatar asked Jul 15 '13 19:07

forlooper


People also ask

What is DESCRIPTION file in R?

Although mostly associated with R packages, a DESCRIPTION file can also be used to declare dependencies for a non-package project. Within such a project, devtools::install_deps() can then be used to install all the required packages. Note that, by default, use_decription() checks for a CRAN-compliant package name.

What is the purpose of the DESCRIPTION file in a package?

The job of the DESCRIPTION file is to store important metadata about your package. When you first start writing packages, you'll mostly use these metadata to record what packages are needed to run your package.

How do I use my Devtools check?

To use DevTools, all you have to do is select Inspect on any page on the internet. You'll then be able to see all of its source code. From that point you can test out various changes, look for the source of problems, and more.


1 Answers

Unfortunately you need:

options(devtools.desc.author="'First Last <[email protected]> [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 = "[email protected]", 
    role  = c("aut", "cre")), 
  "'"
)
options(devtools.desc.author=authors)
like image 182
hadley Avatar answered Oct 12 '22 05:10

hadley