How to include Authors@R in the manual of R package?
Asked Answered
S

3

12

I have the following description file as part of my R package

Package: blah
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors@R: person("Jon", "Snow", email = "[email protected]", role = c("aut", "cre"))
Description: What the package does (one paragraph).
Depends: R (>= 3.5.1)
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.0.9000

I have documented my code and would like to produce a manual that accompanies it. In a previous post, people have mentioned using the command R CMD Rd2pdf <work directory> and I managed to produce a manual.

The issue is that in my manual, the bit before R topics documented does not show the authors but everything else. I have installed packages such as devtools, knitr, roxygen2 and testthat. Any advice would be highly appreciated.

Sebbie answered 10/1, 2019 at 16:34 Comment(1)
You've got a couple of possible answers to your question. It's polite on this site to pick one of them and mark it as "accepted" (you'll see how if you look), or leave comments explaining why they don't quite meet your needs.Sentiment
U
12

If you want to include multiple authors, you have to wrap all persons in c().

See the DESCRIPTION of sf for example, which looks something like this:

Authors@R: 
  c(person(given = "Edzer",
           family = "Pebesma",
           role = c("aut", "cre"),
           email = "[email protected]",
           comment = c(ORCID = "0000-0001-8049-7069")),
    person(given = "Jeroen",
           family = "Ooms",
           role = "ctb",
           comment = c(ORCID = "0000-0002-4035-0289")),
    person(given = "Kirill",
           family = "Müller",
           role = "ctb"))

If there is only one author, you can simply write:

Author: Lax Chan
Umbria answered 10/1, 2019 at 16:41 Comment(0)
S
3

The Authors@R field is reformatted as Author when you build a source package. It won't appear in your source directory, so building the manual from that won't include it.

What you need to do is to build the tar.gz file from the source, then create the manual from that.

Since it seems you are using command line methods, this is done by

R CMD build <workdir>

which produces something like workdir.version.tar.gz. Unfortunately, Rd2pdf can't read this file directly, so you need two more steps. Move to a clean directory, and run

tar zxvf workdir.version.tar.gz
R CMD Rd2pdf workdir

to produce the manual from the built DESCRIPTION file.

(I don't think it would be a disaster if you unpacked the tarball on top of the original source, but it could cause confusion later if you change the DESCRIPTION file.)

Sentiment answered 10/1, 2019 at 17:58 Comment(2)
Thank you very much for your input! this is exactly what I neededSebbie
This worked for me, too, as I also used the Author@R field. My command line didn't like the tar command due to an unexpected end of file, so I simply right clicked and extracted all the files that way.Writein
S
0

Minor note: If you want your authorship to be "Alfred N. Other", I've found you need to use given=c("Alfred", "N.")

Sofar answered 8/11, 2022 at 15:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.