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

Martin Maechler maechler at stat.math.ethz.ch
Mon Jul 23 15:52:54 CEST 2001


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

    Jim> MichaelNielsen at 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 at 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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list