[R] Object "silhouette.default" not found... there.

Martin Maechler maechler at stat.math.ethz.ch
Tue May 25 18:39:13 CEST 2004


>>>>> "Eryk" == Eryk Wolski <wolski at molgen.mpg.de>
>>>>>     on Tue, 25 May 2004 17:38:10 +0200 writes:

    Eryk> Hi!
    >> library(cluster)
    Eryk> In this lib a function called silhoutte.default is defined
    Eryk> than on the R prompt it type
    >> silhouette.default
    Eryk> Error: Object "silhouette.default" not found 
    Eryk> R1.9.0
    Eryk> The same error are at R1.8.1
    Eryk> And I knew that a function silhoutte.default are present.

Hi Eryk,

please do learn about namespaces;  many good R packages (incl.
all standard and recommended packages) nowadays make use of
namespaces, and we expect even more in the future.

One big advantage of 'namespacing a package' is that
you can make sure that your functions call your other functions
even if they have the same name as someone's functions in
another package.  Another big "pro" is that you can use as many
``package-internal'' objects {"helper-functions" in my useR talk}
as you want: They won't be visible to the user and not clutter
the global namespace.
One side effect of namespaces: We usually do not export (S3)
methods such as silhouette.default() :

A user should call silhouette(...) and the method dispatching
chooses the corresponding method.

Now, to see "hidden" objects, you can 

1) use  getAnywhere()	        { getAnywhere("silhouette.default") }
2) use  <namespace>:::<object>  { cluster:::silhouette.default }

and for S3 methods,

3) getS3method("<generic>", "<class>")

   i.e., in this case getS3method("silhouette", "default")

----------

BUT:  You won't see the source code of silhouette.default !

Instead:

  1) Learn how to get and unpack the package source and then
     see    cluster/R/silhouette.R

  2) if "1)" is too difficult,
     open the filename you get from
	   system.file("../cluster/R/cluster")
     in a text editor -- preferably an R-aware one ...
     which gives you a large file with all R source from the
     cluster package.   Now look for what you want.

Regards,
Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><




More information about the R-help mailing list