How can I force R to include contributors (or othe

2019-07-25 07:02发布

问题:

I'm currently writing my first R package, following Hadley Wickham's excellent book on the topic. The section of the book linked above includes examples for adding authors through the package's DESCRIPTION file.

Dr. Wickham notes that "The full list of roles is extremely comprehensive. Should your package have a woodcutter ('wdc'), lyricist ('lyr') or costume designer ('cst'), rest comfortably that you can correctly describe their role in creating your package."

The problem that I'm experiencing is that only people with the 'author' role are included in the output of citation() for the package -- woodcutters, lyricists, and costume designers are not. I'd like for non-author contributors to my package to be included in the citation, but don't want to (incorrectly) list them as authors (i.e., as having the role of "author" / aut).

For example, if I include the following in my DESCRIPTION file (csp is listed as "Consultant to a project"):

Authors@R: c(
    person("John", "Doe", email = "jdoe@example1.com", role = c("aut", "cre")),
    person("Jane", "Smith", email = "jsmith@example2.com", role = "csp", comment = "Provided intellectual overview."))

...citation('mypackagename') will give the following:

To cite package ‘mypackagename’ in publications use:

  John Doe (NA). mypackagename: My package description. R package version 0.1.0.
  https://github.com/link/to/mypackagename

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {mypackagename: My package description},
    author = {John Doe},
    note = {R package version 0.1.0},
    url = {https://github.com/link/to/mypackagename},
  }

In addition, ?mypackagename returns [NA] for the contributor under "Author(s)":

Maintainer: John Doe jdoe@example1.com

Other contributors:

Jane Smith jsmith@example2.com (Provided intellectual overview.) [NA]

Seemingly to get around this, the author of the Hmisc package uses the following in his DESCRIPTION file:

Author: Frank E Harrell Jr <f.harrell@vanderbilt.edu>, with
  contributions from Charles Dupont and many others.

How can I force R to include non-author contributors (of other roles) in the citation() output? Is the Hmisc author's approach best here? It seems like that could break the clean metadata parsing provided by Authors@R, so I'm hesitant to use that approach.

I would be grateful for any pointers!

回答1:

You can't include other roles in citation() output. Check the source of citation(), it parses only the author fields, there is even a note in the source code on it:

    ## <NOTE>
    ## Older versions took persons with no roles as "implied" authors.
    ## Now we only use persons with a name and a 'aut' role.  If there
    ## are none, we use persons with a name and a 'cre' role.
    ## If this still gives nothing (which really should not happen), we
    ## fall back to the plain text Author field.
    ## Checking will at least note the cases where there are no persons
    ## with names and 'aut' or 'cre' roles.

So the only way for you to include other roles is to use plain text description as in the example of Hmisc package.