how to keep functions while remove all other commands
As an alternative to Petr's approach of using separate
directories, one can also write a function (which I find quite
useful in its own right) to separate ls() output by mode, e.g.
"lsd" <- function(splitby=mode, pos=1, ...) {
lsout <- ls(pos=pos, ...)
tapply(lsout,
sapply(lsout, function(x) {splitby(get(x))}),
invisible)
}
Given that, you can use expressions such as
rm(list=lsd()$numeric)
rm(list=lsd(splitby=class, all.names=T)$integer)
or to remove functions,
rm(list=lsd()$"function") # nb reserved word function needs quotes
this latter also removes `lsd` itself, so do also follow the advice
re keeping a copy of all your functions in a text file somewhere!
-----Original Message----- On 24 Jan 2004 at 21:47, Yong Wang wrote:
Dear all: a quick question: I am used to apply rm(list=()) regularly to remove all old codes in preventing them creeping in current analysis.however, with that application, functions I wrote are also removed. please let me know how to keep the thing you want while remove those you don't.
Simon Fear Senior Statistician Syne qua non Ltd Tel: +44 (0) 1379 644449 Fax: +44 (0) 1379 644445 email: Simon.Fear at synequanon.com web: http://www.synequanon.com Number of attachments included with this message: 0 This message (and any associated files) is confidential and\...{{dropped}}