[Rd] Best practices in developing package: From a single file
h.wickham at gmail.com
Wed Jan 31 05:39:14 CET 2018
On Tue, Jan 30, 2018 at 4:55 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 30/01/2018 4:30 PM, Kenny Bell wrote:
>> In response to Duncan regarding the use of roxygen2 from the point of view
>> of a current user, I believe the issue he brings up is one of correlation
>> rather than causation.
> Could be. However, I think editing comments in a .R file is a bit harder
> than editing text in a .Rd file, so I think the format discourages editing.
> I think it does make it easier to pass R CMD check the first time, but I
> don't think you should be satisfied with that.
One counter-point: I find it much easier to remember to update the
documentation when you update the code, if the code and the
documentation are very close together. I think mingling code and
documentation in the same file does add a subtle pressure to write
shorter docs, but I'm not entirely sure that's a bad thing - for long
form writing, vignettes are a much better solution anyway (since you
often want to mingle code and explanation).
Personally, I don't find writing in comments any harder than writing
in .Rd files, especially now that you can write in markdown and have
it automatically translated to Rd formatting commands. And on the
negative side of Rd, I find it frustrating to have to copy and paste
the function definition to the usage section every time I modify an
argument. It just feels like unnecessary busywork that the computer
should be able to do for me (although I do understand why it is not
>> Writing my first piece of R documentation was made much easier by using
>> roxygen2, and it shallowed the learning curve substantially.
> I'm not completely up to date on Roxygen2 these days: can you do some pages
> in Rd, others in Roxygen? That's not quite as good as being able to switch
> back and forth, but it would allow you to start in Roxygen, then gradually
> move to Rd when editing there was easier.
Yes, that's possible, and to protect you in mixed environment,
roxygen2 will never overwrite a file that it did not itself create.
More information about the R-devel