Re: [R] Hiding a function from ls()

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Thu 22 Dec 2005 - 20:44:00 EST

>>>>> "Erich" == Erich Neuwirth <erich.neuwirth@univie.ac.at>
>>>>> on Thu, 22 Dec 2005 10:06:38 +0100 writes:

    Erich> I need to define a small helper function     Erich> which should not be listed by ls().

    Erich> What is the best and cleanest way of achieving this?

"it depends":

  1. if it's part of a package, the best and cleanest is
    • have the package use a namespace
    • do nothing special at, so your helper function is not exported from the namespace, and hence not much visible at all.

   The encouraged use of much more such helper function    (i.e. "modular programming") is one prominent reason    for using name spaces.

2) If it's just part of a small script {anything else should be

   in a package anyway :-)},

   just start the function name with a "." (dot).    Then, ls() only would list it when used with the additional    argument setting ls(..., all.names = TRUE)

Martin Maechler, ETH Zurich



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Dec 22 20:50:30 2005

This archive was generated by hypermail 2.1.8 : Thu 22 Dec 2005 - 23:42:24 EST