Search functions in the R-library

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

Suppose I need a list of all the functions in a "graphics" library. How to do it?

If I want to find specific documentation for the "plot" command, I had problems finding documentation when I used help.search ("plot"). This gives me all these functions from different libraries. I just want to find and narrow my search when I search for a specific function.

+4
source share
4 answers

To list all the functions inside the package and links to their documentation, do:

help(package = "graphics") 

This, 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 searches all documents and returns every hit, very similar to a Google search.

Finally, know that you can use:

  • ?plot as a shortcut to help("plot")
  • ??plot as a shortcut to help.search("plot") .
+6
source

Here is an example with 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 as a 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) 
+4
source

Brian Ripley's answer to R-help

ls("package:ts")

will display all the objects in the package (I assume that the package, not the library, meant: the library is the installed packages directory).

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

lsf.str("package:ts")

which also provides call sequences.


unknownR

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

This is a tool for searching the functions of the top packages (helps you find out unknown unknowns)

+3
source

If you are looking for a function in the foo package, sometimes ??foo works fine.

0
source

Source: https://habr.com/ru/post/1437923/


All Articles