I've extracted the function for rm()
in R (because I'm annoyed at having to type rm(list=ls())
everytime I want to clear my environment; it get's dirty fast) and I've tried modifying it to automatically use the list=ls()
code but it hasn't worked. Can anyone else figure out a way to edit this function to automatically do what rm(list=ls())
does but not delete itself.
function (..., list = character(), pos = -1, envir = as.environment(pos),
inherits = FALSE)
{
dots <- match.call(expand.dots = FALSE)$...
if (length(dots) && !all(sapply(dots, function(x) is.symbol(x) ||
is.character(x))))
stop("... must contain names or character strings")
names <- sapply(dots, as.character)
if (length(names) == 0L)
names <- character()
list <- .Primitive("c")(list, names)
.Internal(remove(list, envir, inherits))
}
FYI:
clr <- rm(list=ls())
doesn't work either.