Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best practice in attaching R scripts with examples to an R package?

Tags:

package

r

I wonder what is the best practice in attaching R scripts with examples to an R package. I mean R script with examples such as:

  • go somewhere beyond simple function running example (e.g. come with plot with visualization), have 10-30 lines of code and thus seem for me too long to put them as "Example" in the package documentation
  • are extracts from larger paper which will go as a vignette to the package itself, so it seems for me maybe not the best idea to include it as just another vignette, shorter than this main one

I am not sure if there are any other "elegant" ways of including such examples.

like image 330
Marta Karas Avatar asked Dec 07 '25 07:12

Marta Karas


1 Answers

I would use

  • the demo/ directory, or
  • an inst/examples/ directory

The former leads to use by demo() and has some extra requirements spelled out in Writing R Extensions, the latter is simpler.

Lastly you of course just write a vignette document ...

like image 112
Dirk Eddelbuettel Avatar answered Dec 09 '25 22:12

Dirk Eddelbuettel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!