A previous attempt at this question resulted in the message running together, making the message difficult to read and the code lines hard to distinquinsh. 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 7 R version 2.14 beta Thanks in advance, Tyler Rinker
[[alternative HTML version deleted]] ______________________________________________ R-help@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.