Possible Duplicate:
How do you you determine the namespace of a function?
I don’t know how to do this… How do you know the package name for a certain function in R? I would like to have a function that given the name of a function, returns the name of the package that owns it. Any suggestion?
There may be better solutions, but
find("functionname")seems to work reasonably well? However, it only works for loaded packages.(If you need the raw name of the package you can use
gsub("^package:","",results))(The answers to the previous question linked by Andrie include this answer; they don’t give the bit about
gsub, and they all seem to share the issue of not finding non-loaded packages.)Here’s a quick hack to find functions even in non-loaded packages:
If you need to find functions in non-installed packages (i.e. searching CRAN), then
findFnfrom thesospackage will be your friend.