One option that I have not seen mentioned yet, and may be the most similar to the Python approach is to name the "Invisible" function starting with a "." (the period). Then the function will not appear when you do `ls()` but is still accessible. It however is not limited in scope and it is still callable by anyone (and `ls(all=TRUE)` will show it). This does not give the control that packages or local environments do, but it is a quick and easy way to have something that "hidden".
On Fri, Jan 31, 2014 at 11:46 AM, Paul A. Steckler <st...@stecksoft.com> wrote: > I'm fairly new to R, and have checked the R FAQ and done an RSiteSearch for > help > on this topic, to no avail. > > I want to write some R code that has functions at the top-level that > are not visible when > the code is loaded. So in > > fun1 <- function(...) { ... } > > fun2 <- function(...) { ... fun1 ...} > > I'd like fun2 to be callable, but have fun1 be invisible. That is, the > scope of fun1 is > limited to the file in which it's defined. > > In Python, I believe that prepending an underscore to a variable name > limits its scope in this way. > Is there a similar mechanism in R? > > -- Paul > > ______________________________________________ > R-help@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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com ______________________________________________ R-help@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.