Learn R Programming

testthat (version 0.9.1)

library_if_available: Load package, if available.

Description

Quietly load a package if it is installed, otherwise do nothing. This is useful for testing files so that you can run them while you are developing your package, before it is installed for the first time; then continue to have the same code work when the tests are run automatically by R CMD CHECK.

Usage

library_if_available(package)

Arguments

package
package name (without quotes)

Examples

Run this code
library_if_available(testthat)
library_if_available(packagethatdoesntexist)

Run the code above in your browser using DataLab