2

Since initially running package.skeleton to create a package, I have added several S3 classes. Each of these classes has 5-10 methods. I've discovered the wonderful prompt command to create .Rd files from a function loaded into memory, but is it possible to have R automagically create a single help file that has all multiple functions documented? I'm thinking of something like an enhanced version of prompt where you would pass it a list of functions, and it would create a single .Rd file with only the additional information added to the help file.

For instance, if I have a generic called duration, and classes for which there are methods duration.bond(market,...), duration.account(market,time,...), duration.portfolio(market,...), I would like prompt to create a helpfile with a \usage section containing each \method{} and an \arguments{} section containing market,\dots, and time.

Any hope here? Copying and pasting is getting very tiring!

Ari B. Friedman
  • 71,271
  • 35
  • 175
  • 235
  • bond(), account(), ... seem like methods / functions to me, not classes. If they're classes, your question is rather confusing... – Joris Meys Jul 27 '11 at 12:41
  • They're functions to create objects of a particular class. So duration is the generic and I have duration.bond, duration.account, duration.portfolio methods/functions. But you're right the second paragraph is confusing. Going to re-word. – Ari B. Friedman Jul 27 '11 at 13:10
  • One possibility Roman pointed out is just to use ROxygen. I'll likely do that for future projects, but for this one.... The stopgap approach is just to pick the method that has the most arguments and use `prompt` on that. Not the most elegant approach, however. – Ari B. Friedman Jul 27 '11 at 13:19

2 Answers2

1

For completeness, adding in what I chose to do here, which is to pick the method that has the most arguments and use prompt on that, then add in the other methods manually to the same help file.

The other alternative would have been to use Rd2roxygen to convert everything that was already in .Rd back to Roxygen and then use Roxygen for the whole project. This will likely be what I do in the next release.

Ari B. Friedman
  • 71,271
  • 35
  • 175
  • 235
0

You could roll-your-own by reading in a template help file (with readLines), then editing it to suit each particular case (judicious use of paste and gsub), then writing the result back out to file (via writeLines).

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360