Uses(package, [lib], [repos], [quiet], [attachImports])

package – character vector containing name of package, e.g. “drc”

lib – character vector containing path to library directories to install package if needed

repos – list of repositories to use to download package if needed

quiet – TRUE or FALSE (default) flag indicating whether interactive dialogs should be suppressed during package installation

attachImports – TRUE OR FALSE (default) flag indicating whether or not attach imports from the package and its dependencies to the current R session

The Uses() function can be used to ensure that the respective package (library) named package AND its dependencies (packages that are required in order for this package to run) are installed (on the computer/server where the R script is running) and loaded into the R environment automatically. If some of these libraries are not present, they will be installed and then loaded.

R defines several levels for specification of package dependencies. One of them is Imports – it lists packages with namespaces that have to be loaded for the package to run, but the namespaces do not need to be attached to the current/global environment, meaning that the package accesses such imported packages using namespace-qualified names, e.g., tseriesChaos::mutual(x) instead of mutual(x). If you need to use some of these namespace-enclosed functions in your own R code, you can either explicitly use namespace qualification [tseriesChaos::mutual(x)], attach the library to current environment [Uses(“tseriesChaos”) or library(tseriesChaos)], or set the optional Uses() parameter attachImports to TRUE (this will attach all the imports of the package).

Note that this extension is not necessary for interaction between Statistica and R, and it’s possible to implement it within the R language itself; rather, it simplifies the process of conditional library installation and loading by encapsulating it in a single call.

Example:

Uses("drc") # make sure that the respective package is installed and loaded

DR <- multdrc(SLOPE ~ DOSE, CURVE, data = PestSci) # call the package methods

This program fits dose response curves to the respective variables of the built-in PestSci data set by calling multdrc function defined in “drc” package. Uses(“drc”) ensures that the function is available by installing and loading the package, if necessary.