How to force installation of required packages in TERR

How to force installation of required packages in TERR

book

Article ID: KB0083383

calendar_today

Updated On:

Products Versions
Spotfire Enterprise Runtime for R All

Description

How to code TERR data functions so that any packages needed are installed automatically in the background prior to execution of the data function's TERR script.

Issue/Introduction

Set up data function to install package in TERR if not already present

Environment

Product: TIBCO Enterprise Runtime for R (TERR) Version: All supported versions OS: All supported Operating Systems

Resolution

Add the following line of code to the beginning of your code:

####
if (!require(packageName)) install.packages("packageName")
####

The require() function looks to see if the package is available, i.e. installed, and if it isn't it will trigger the install.packages() function call.

Additional Information

More information is provided on the require() and install.packages() functions in the TIBCO Enterprise Runtime for R (TERR) help files that are opened in a web browser when the following commands are issued in a TERR Console session:

     ?require
     ?install.packages