Get the list of functions loaded in R's global environment [duplicate]

北慕城南 提交于 2020-05-07 12:33:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!