# Wait for the selected packages and # any other packages they depend on # to be downloaded and installed. # There will be informational messages # for each package.
sapply( X = PackagesToLoad, FUN = function(X) library(X, character.only = TRUE)) #-----
The following is an example of its use, in a TERR 5.0.0 Console session on a Windows machine that has internet access to the open-source R community's CRAN repository:
===== TIBCO Software Inc. Confidential Information Copyright (C) 2011-2019 TIBCO Software Inc. ALL RIGHTS RESERVED TIBCO Enterprise Runtime for R version 5.0.0 for Microsoft Windows 64-bit
Type 'help()' for help. Type 'q()' to quit. > > > > R.home() [1] "C:/Program Files/TIBCO/terr500" > > > version$version.string [1] "TIBCO Enterprise Runtime for R version 5.0.0 (2019-01-15)" > > > getRversion() [1] '3.5.1' > > > installed.packages(lib = .libPaths()[1])[, "Version"] character(0) > > > > search() [1] ".GlobalEnv" "package:stats" "package:graphics" [4] "package:grDevices" "package:utils" "package:methods" [7] "package:base" > > > > > > #----- > PackagesToLoad <- c("dbscan", "plyr", "dplyr") > > PkgsToInstall <- setdiff(PackagesToLoad, rownames(installed.packages())) > > if( length(PkgsToInstall) ) { install.packages(PkgsToInstall) } > > # ... > > # Wait for the selected packages and > # any other packages they depend on > # to be downloaded and installed. > # There will be informational messages > # for each package. > > sapply( X = PackagesToLoad, FUN = function(X) library(X, character.only = TRUE))
The following object(s) are masked _from_ 'package:plyr': arrange, count, desc, failwith, id, mutate, rename, summarise, summarize
The following object(s) are masked _from_ 'package:stats': filter, lag
The following object(s) are masked _from_ 'base': intersect, setdiff, setequal, union
Disclaimer: The code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment. Make modifications to the code in accordance with your implementation specifications that best suit your business requirements. Refer to the reference(s) cited in this article for usage of the functions and methods used in the code.
Important note on use of CRAN packages:
User-contributed R packages from the open-source R community's CRAN repository (https://cran.r-project.org/) are available under separate open source software license terms and are not part of the TIBCO Spotfire product line. As such, user-contributed CRAN packages are not within the scope of your license for any TIBCO Spotfire product. User-contributed CRAN packages are not supported, maintained, or warranted in any way by TIBCO Software Inc. Download and use of CRAN packages is solely at your own discretion and subject to the free open source license terms applicable to each individual package.
Issue/Introduction
Example TERR script that installs a group of CRAN packages before loading them via calls to library()
Additional Information
In a TERR Console session, the following commands will open online help topics for TERR functions, operators, objects and syntax structures (such as the if() clause) used in this article: