Re: [R] Hiding information about functions in newly developed packages

From: Marc Schwartz <marc_schwartz_at_comcast.net>
Date: Thu, 17 Jul 2008 12:09:11 -0500

on 07/17/2008 10:57 AM Tudor Bodea wrote:
> Dear UseRs:
>
> I intend to write a package to handle the basic operations a revenue management
> analyst has to deal with on a regular basis (e.g., demand untruncation,
> capacity allocation, pricing decisions, etc.). Following the directions posted
> by Peter Rossi (Making R Packages under Windows: A Tutorial, January 2006) I
> was able to build an interim package that currently consists of one simple
> function (e.g., fun). After the package is loaded and the function is invoked
> without any parameters (e.g., > fun) the body of the function is displayed on
> the screen underneath the function call. Since the user does not need to know
> the internal structure of the function, I am wondering if there is a way to
> hide this information. I have looked into some of the material that Paul
> Murrell and John Chambers among others posted but I have not really understood
> how to incorporate this information into the package building process. If you
> already experienced this issue and have some useful suggestions, I would really
> appreciate your taking the time to share them with me. For this project, I am
> using R2.7.1 on a Windows XP machine.
>
> Thank you.
>
> Tudor

Do you want to have the function hidden in a 'namespace' or to actually attempt to keep the user from seeing your R source code at all?

The latter is impossible in R.

For the former, see that "Writing R Extensions" manual:

http://cran.r-project.org/doc/manuals/R-exts.html#Package-name-spaces

and the following article by Luke in R News:

Luke Tierney. Name space management for R. R News, 3(1):2-6, June 2003

You could 'export' a wrapper function called fun(), but not export the main working internal function called fun.internal().

   fun <- function(...) fun.internal(...)

However, the body of the wrapper function would still be seen and if the user knows how to 'get' to functions within namespaces, they will be able see the full body of the internal function.

HTH, Marc Schwartz



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. Received on Thu 17 Jul 2008 - 17:11:34 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 Thu 17 Jul 2008 - 17:31:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive