[R] Hiding information about functions in newly developed packages

Bert Gunter gunter.berton at gene.com
Thu Jul 17 19:07:41 CEST 2008


You seems to be confused here. A function is "invoked" -- i.e. "called" --
via the expression

fun(...) ##  *Note the parentheses.* The function body is *not* printed. 

The expression
 
fun   ## note: no parentheses

is not a call to the function. Rather, it is by default a call to the
**print** method for the object, fun; when fun is a function, this prints
the body of the function. One could change this by changing the S3 or S4
class of the object and defining the "print" or "show" method, respectively,
to be something other than the standard "print the body of the function." I
don't think this is necessarily a good idea, though. 

Incidentally, if the function is invoked without arguments ** that it needs
and for which defaults have not been provide** then you'll get an error. 

Details on this can be found in ?print, ?print.default ?show   and the
relevant documentation on S3 and S4 methods (e.g. ?UseMethod ,?setClass,
?setMethod and various R docs).

Perhaps before you write your package you would do well to do some more
studying of the R language.

Cheers,

Bert Gunter
Genentech


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Tudor Bodea
Sent: Thursday, July 17, 2008 8:58 AM
To: r-help at stat.math.ethz.ch
Cc: Tudor Bodea
Subject: [R] Hiding information about functions in newly developed packages

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



--
Tudor Dan Bodea
Georgia Institute of Technology
School of Civil and Environmental Engineering
Web: http://www.prism.gatech.edu/~gtg757i

______________________________________________
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