Re: [R] How to pack my stuff into a package (library, collection)?

From: Duncan Murdoch <>
Date: Tue, 08 Apr 2008 08:38:24 -0400

On 08/04/2008 7:08 AM, Tribo Laboy wrote:
> Thanks all for the help and suggestions. I am little by little finding
> my way. I have another question to the people who use the R packaging
> system. Say I have a function called "myfun.R".

I guess you mean you have a source file myfun.R, containing a definition of a function myfun. You would put this in the R subdirectory of the package. (You could have a function named myfun.R, but it looks a little strange.)

Where am I supposed to
> write the help to that function? When I use promt("myfun") or
> package.skeleton("myfun") I get a skeleton of the .Rd file which
> contains both help and R source. What do you do with the original .R
> source file then - do you delete it? I suppose it is not necessary
> anymore and all changes to R source and help can be done
> simultaneously in the .Rd file.

No, definitely not. The source is copied to the Rd file just to remind you of what the function looks like, so that you can write documentation that is correct. By the time you're finished editing that file, you'll have actual working examples in the Examples section, not the function definition. You'll put the .Rd file into the man subdirectory of the package; R uses the \alias{myfun} line at the top to find the connection to your myfun function.

There is a proposal on the Google Summer of Code page to mix documentation with definitions in the .R file, but so far we don't do that.

  Then it can be used to generate all
> the help and R files to be run. But then .Rd files cannot be run
> directly from R, so each time a change is done to the source, it must
> be re-exported in an .R file and run. Please tell me if I am wrong. Do
> you keep R-souce and R-help in separate files while developing and
> then combine them in a single .Rd file when you're finished?

No, they are separate from the beginning, and stay separate.

Duncan Murdoch mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 08 Apr 2008 - 12:42:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Apr 2008 - 13:30:27 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive