use {base}R Documentation

Use Packages


Use packages in R scripts by loading their namespace and attaching a package environment including (a subset of) their exports to the search path.


use(package, include.only)



a character string given the name of a package.


character vector of names of objects to include in the attached environment frame. If missing, all exports are included.


This is a simple wrapper around library which always uses attach.required = FALSE, so that packages listed in the Depends clause of the DESCRIPTION file of the package to be used never get attached automatically to the search path.

This therefore allows to write R scripts with full control over what gets found on the search path. In addition, such scripts can easily be integrated as package code, replacing the calls to use by the corresponding ImportFrom directives in ‘NAMESPACE’ files.


(invisibly) a logical indicating whether the package to be used is available.


This functionality is still experimental: interfaces may change in future versions.

[Package base version 4.4.0 Index]