There may be better solutions, but find("functionname")
seems to work quite well? However, it only works for downloaded packages.
> find("strwidth") [1] "package:graphics" > find("qplot") character(0) > library(ggplot2) > find("qplot") [1] "package:ggplot2" >
(If you need a raw package name, you can use gsub("^package:","",results)
)
(The answer to the previous question related to Andrie includes this answer: they don't give a bit about gsub
, and they all seem to be unable to find unsupported packages.)
Here you can quickly find functions even in unloaded packages:
findAllFun <- function(f) { h <- help.search(paste0("^",f,"$"),agrep=FALSE) h$matches[,"Package"] } findAllFun("qplot") ## "ggplot2" findAllFun("lambertW") ## "emdbook" "VGAM" > findAllFun("xYplot") ## "Hmisc" "lattice"
If you need to find functions in non-installed packages (i.e. CRAN search) then findFn
from sos
package will be your friend.
source share