6

New to the forum. Is there a way to search for functions within a particular library in R?

Lets say I would like a list of all the functions in the "graphics" library. How would do that?

If I want to find the specific documentation on the "plot" command I am having trouble finding the documentation when I used the help.search("plot"). It gives me all these other functions from different libraries. I just want to be able to find and narrow down the searches when I look for a particular function.

2

4 Answers 4

7

For a listing of all the functions within a package, and links to their documentations, do:

help(package = "graphics")

That of course assumes that you have installed the package.


For your other question:

If you already know the name of the function you are looking for, do not use help.search("plot") but help("plot"). As the name suggests, help.search does a search through all the docs and returns every hit, very much like a Google search.

Finally, know that you can use:

  • ?plot as a shortcut to help("plot")
  • ??plot as a shortcut to help.search("plot").
Sign up to request clarification or add additional context in comments.

1 Comment

Flodel your awsome. Can't thank you enough. Hope you get this message.
4

Here's an example with the package graphics:

library(graphics)   #first load the package 
OBJS <- objects("package:graphics")    #use objects to look at all objects
DS <- data(package="graphics")[["results"]][, "Item"]   #find the data sets
OBJS[!OBJS %in% DS]  #compare to data sets

Here it is wrapped up as function:

funs <- function(package) {
    pack <- as.character(substitute(package))[1]
    require(pack, character.only = TRUE)
    OBJS <- objects(paste0("package:", pack)) 
    DS <- data(package=pack)[["results"]][, "Item"]  
    OBJS[!OBJS %in% DS]  
}

funs(graphics)

Comments

3

An answer from Brian Ripley on R-help

ls("package:ts")

will list all the objects in the package (I presume package and not library was meant: a library is a directory holding installed packages).

If you really want to know about the functions (and not all objects) in a package try

lsf.str("package:ts")

which gives the call sequences too.


unknownR

I will also spruik the unknownR package. There is a nice demonstration here.

It is a tool to go search through functions top packages (helps you learn your unknown unknowns)

Comments

0

If you are looking for a function in package foo, sometimes ??foo works quite good.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.