[R] recover lost global function

MacQueen, Don macqueen1 at llnl.gov
Thu Apr 5 16:48:16 CEST 2012


To expand on Duncan's answer, you haven't replaced it. The following
should make that clear:

## starting in a fresh session
> c
function (..., recursive = FALSE)  .Primitive("c")
> find('c')
[1] "package:base"
> c <- 1
> find('c')
[1] ".GlobalEnv"   "package:base"
> c
[1] 1
> rm(c)
> find('c')
[1] "package:base"
> c
function (..., recursive = FALSE)  .Primitive("c")

The one provided by R, and the one you created, are not in the same
namespace.
To "recover" R's version, get rid of the one you created.Also, take a look
at the search() and conflicts() functions.

-Don


-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/4/12 1:52 PM, "Sam Steingold" <sds at gnu.org> wrote:

>Since R has the same namespace for functions and variables,
>> c <- 1
>kills the global function, which can be restored by
>> c <- get("c",mode="function")
>
>Is there a way to prevent R from overriding globals
>or at least warning when I do that
>or at least warning when I replace a functional value with non-functional?
>
>thanks.
>
>-- 
>Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X
>11.0.11004000
>http://www.childpsy.net/ http://iris.org.il http://camera.org
>http://ffii.org
>http://dhimmi.com http://mideasttruth.com http://pmw.org.il
>Garbage In, Gospel Out
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list