[R] Inadvertent clobbering [was `Strange behaviour of spectrum()?']

About this list Date view Thread view Subject view Author view Attachment view

From: Martin Maechler (maechler@stat.math.ethz.ch)
Date: Mon 23 Jul 2001 - 23:52:54 EST


Message-id: <15196.11318.168303.433830@gargle.gargle.HOWL>


>>>>> "Jim" == Jim Lemon <bitwrit@ozemail.com.au> writes:

    Jim> MichaelNielsen@synergy.com.au wrote:
>>
>> ... it raises the question about how R-guru's manage inadvertent
>> clobbering of magic names. Constructive suggestions would be warmly
>> received.

you just know the dangerous names and don't reassign them .... :-) ;-)

As a matter of fact, there are only very few global "non-functions"
The following one-liner (:-) shows them :

> for(ip in 2:length(search())) {cat("pos = ",ip,": ",search()[ip],"\n========\n");if(length(nms <- ls(pos=ip)))print(nms[sapply(nms,function(n)!is.function(get(n,pos=ip)))])}

pos = 2 : package:ctest
========
character(0)
pos = 3 : Autoloads
========
pos = 4 : package:base
========
 [1] ".AutoloadEnv" ".Device" ".Devices"
 [4] "F" ".GlobalEnv" "Hershey"
 [7] "ISOLatin1" ".Last.value" ".leap.seconds"
[10] "LETTERS" "letters" ".lib.loc"
[13] ".Library" ".Machine" "MacRoman"
[16] "month.abb" "month.name" "native.enc"
[19] ".Options" "p.adjust.methods" ".Pars"
[22] ".Pars.readonly" "pi" ".Platform"
[25] ".PostScript.Options" ".ps.prolog" "R.version"
[28] "R.version.string" "T" "version"
[31] "WinAnsi"

Hence it's
      T , F , pi
      letters, LETTERS, version, month.name, month.abb, Hershey
(and a few more at most)
that you would care about.

    Jim> Caveat: I am no guru
    Jim> Suggestion: There is a little function I included in "Kickstarting R"
    Jim> that might help you.

    Jim> dup.name <- function(name) {
    Jim> if(is.character(name))
    Jim> return(length(grep(name,objects(1:length(search())))) > 0)
    Jim> cat("Usage: dup.name(name)\n\twhere name is a character string\n")
    Jim> }

I think you should use the standard function
  conflicts()

Martin

Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO D10 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 10 Mar 2004 - 08:18:21 EST