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

From: Bert Gunter <gunter.berton_at_gene.com>
Date: Thu, 17 Jul 2008 10:07:41 -0700

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.
______________________________________________
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:30:17 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