开发者

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

开发者 https://www.devze.com 2023-02-13 16:54 出处:网络
This question already has answers here: 开发者_如何转开发Closed 11 years ago. Possible Duplicate:
This question already has answers here: 开发者_如何转开发 Closed 11 years ago.

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?


See ?lsf.str

X <- lsf.str()
as.vector(X) # just for printing purposes, you can use the vector in rm()
rm(list=X)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消