In my R learning I've come across a situation in which a piece of code that
works on the work space outside a function does not work inside the function.
WARNING THIS EMAIL CONTAINES THE CODE:#rm(list=ls()) THIS WILL CLEAR ALL
OBJECTS FROM YOUR WORKSPACE! When I use rm(list=ls()) and then ls() it shows
character(0) So I tried to make a quick function to speed this up as follows:
#====================
# ATTEMPT 1
#====================
clear <- function()rm(list=ls())clear()ls() #all objects are still attached
#====================
# ATTEMPT 2
#====================
clear <- function(){
{CLEAR <- function()rm(list=ls())}
eapply(globalenv(),CLEAR)
}clear()ls()
#============================
#ERROR MESSAGE FRPM ATTEMPT 2
#============================
> clear()
Error in FUN(list(function (x) : unused argument(s) (list(function (x)
QUESTIONS:Why does this code not work inside the function? Please critique
both my attempts?What would I need to do to make the pieces of code work inside
the function? Windows 7R 2.14 beta Thanks in advance,Tyler Rinker
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.