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

From: Martin Maechler <>
Date: Thu 22 Dec 2005 - 20:44:00 EST

>>>>> "Erich" == Erich Neuwirth <>
>>>>> 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 mailing list PLEASE do read the posting guide! 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