问题
Possible Duplicate:
Is there a way to get a vector with the name of all functions that one could use in R?
Hi
I would like to get from R the list of functions loaded in the environment.
I know ls()
that gives the list of objects loaded. But some objects are not functions.
I would like to clean my env from the functions but not from the other objects (matrices, array etc) that contain some of my result that dont want to lose.
Any idea?
回答1:
See ?lsf.str
X <- lsf.str()
as.vector(X) # just for printing purposes, you can use the vector in rm()
rm(list=X)
回答2:
ok, I have a proposal
rm(list=ls()[sapply(ls(), function(obj) "function"==class(eval(parse(text = obj)))[1])])
I am sure there is something more elegant.
来源:https://stackoverflow.com/questions/5103194/get-the-list-of-functions-loaded-in-rs-global-environment