Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a command in R to view all the functions present in a package? [duplicate]

Tags:

r

I would like to know if there is a command, using which one can view all the functions that are built into an R package.

For example, let's say I loaded a package into environment:

require(dplyr) 

Now, I would like to get a list of all the functions present in the dplyr package.

Is there any way to get such a list?

like image 837
LearneR Avatar asked May 22 '15 09:05

LearneR


People also ask

How do I see all functions in an R package?

We can find the functions inside a package by using lsf.

How do I see package data in R?

If you look at the package listing in the Packages panel, you will find a package called datasets. Simply check the checkbox next to the package name to load the package and gain access to the datasets. You can also click on the package name and RStudio will open a help file describing the datasets in this package.

How do I view a function in RStudio?

A shortcut in R Studio is to put the cursor on the function name and press F2 . It's a nice feature when digging through nested functions.


1 Answers

You can use lsf.str.

For instance:

lsf.str("package:dplyr") 

To list all objects in the package use ls

ls("package:dplyr") 

Note that the package must be attached.

To see the list of currently loaded packages use

search() 

Alternatively calling the help would also do, even if the package is not attached:

help(package = dplyr) 

Finally, you can use RStudio which provides an autocomplete function. So, for instance, typing dplyr:: in the console or while editing a file will result in a popup list of all dplyr functions/objects.

like image 159
nico Avatar answered Sep 19 '22 06:09

nico