[R] New unique name

Duncan Murdoch dmurdoch at pair.com
Mon Apr 19 16:50:43 CEST 2004


I think the function below will tell you all the names that are in
scope at the point where it is called.  You can then make up something
that's not in the list.

Duncan Murdoch

all.names <- function() {
    env <- new.env(parent=parent.frame())
    result <- ls(env=env)
    while (!is.null(env)) {
        env <- parent.env(env)
        result <- c(result, ls(env=env))
    }
    sort(unique(result))
}




More information about the R-help mailing list