[R] R Example scripts

Duncan Murdoch murdoch.duncan at gmail.com
Sat Apr 19 13:12:04 CEST 2014


On 18/04/2014, 6:07 PM, Gene Leynes wrote:
> A few years ago R changed the way help was handled so that the HTML
> files are no longer available in the library directory.  Around that
> time the R example files that used to be in some of the libraries also
> vanished.
>
> I'm wondering where the "r-ex" folder went. Is it totally unsupported
> and gone? Is it hidden in the mysterious rdx or rdb files?

The source for the examples will be in the \examples{} section of the 
.Rd source file -- that didn't change.  What changed was how the source 
is processed.  The files are now parsed into a binary format that is 
stored in the database files.

You can extract the examples from the source file using the tools::Rd2ex 
function.  You can extract them from the binary database using this 
function on an Rd object, which is obtainable using the internal 
function .getHelpFile.

So for example, to see the code for the example for rwishart, you could do

tools::Rd2ex(".../bayesm/man/rwishart.Rd")

if you have the source file installed there, or

library(bayesm)
Rd <- utils:::.getHelpFile(?rwishart)
tools::Rd2ex(Rd)

if you have the package installed.

Duncan Murdoch
>
> In particular I'm looking for the latest example scripts in the baysem
> package. I don't see them in the source code or the installed library.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list