Wednesday, October 21, 2015

How to view all functions and other details of a package in R

While we are working with some packages in R, we sometimes want to know other functions from that package that may be available at our disposal.

Note: Make sure that the package is installed. Else, you may get an error that the package was not found. 

If you get that error, make sure to install the package. For installation, refer to the post: Installing and loading packages

In order to bring up information on any given package, use the following command:

search(help = package_name)

For example:

search(help = xgboost)

If you are using R (and not R Studio), this command will open a new window that would provide high level documentation about the package. The information is mainly divided into two sections: Description and Index.

Description provides general information about the package. Index provides names of all the functions that are available in the package.

Once we have the list of functions available, we can find more information about a particular function using the following command:

?function_name

For example:
?xgb.save()

This command will open up web page that provides detailed documentation about the function we need help with.

Now that we know how to install and view details of any given package, we would learn about some housekeeping in R next in the series.


No comments:

Post a Comment