Adding CRAN Packages to an existing SPK to put on Spotfire Server

By editing the DCF and then running a few lines of TERR code, you can add packages to a Spotfire SPK that you can deploy to Spotfire Server for use by the TERR service and the Spotfire Web Player.

You can create an SPK containing packages, you can add a package to an existing SPK, or you can remove a package from an SPK. This topic demonstrates adding two packages to an existing SPK by first downloading the packages, and then adding their names to the DCF that specifies the package contents, and finally uploading the resulting SPK to the Spotfire Server.

Perform this task from the TERR console. Always use the version of TERR that is installed with your TERR service.

  • On Windows, you can perform this task either from TERR running on the command line, or from the TERR console available from the TERR Tools menu in Spotfire Analyst.
  • On Linux, perform this task from TERR running on the command line.

Prerequisites

  • You must have access to the TERR console, version 4.5 or later.
  • You must have access to the original DCF that contains the packages in the original SPK.
    Tip: The DCF is written to the default location for writeLines(), unless you specify another location.
  • You must have access to the Spotfire Server deployment area.
  • You must have access to an internet connection that allows you to download packages from CRAN.
  • You must build a package for the operating system on which your Spotfire Server node manager is installed.
  • For Linux operating systems, you must first install the rinclude package before installing the packages for your SPK. The rinclude package is needed for compiling from source.

Procedure

  1. From the TERR console, install the packages you want to add.
    This example shows adding two packages. As of TERR version 5.1, the function that builds the SPK includes all Includes and Depends packages in the SPK. In versions earlier than TERR 5.1, you must manually include any Depends packages if they are needed for your scripts.
    #example
    install.packages(c("caret,forecast"))
    Note: If you are running Windows, you can install the packages you want in Spotfire Analyst, from the TERR Tools Package Management dialog box.
  2. Open the DCF containing the original packages in a text editor.
  3. Find the line containing the packages. "Packages: plyr,zoo".
  4. Add the new package names to the list, and then save the DCF.
    Do not change any other lines in the DCF.
    "Packages: plyr,zoo,caret,forecast".
  5. In the TERR console, call the function that creates the SPK, and pass in the name of the DCF you edited and the file name of the original SPK. Additionally, explicitly provide the name of the package to display in the Deployments and Packages list on Spotfire Server.
    The name of the SPK to display in the Deployments and Packages list is needed to differentiate the manually-edited file from the TERR-built file. You can provide the default, or you can provide a different string.
    buildServerSPK("ServerSPK.dcf", "ServerSPK.spk", spkName="Approved CRAN Packages")
    The Spotfire package file is created, and the file ServerSPK.dcf now contains the new packages, as well as all Includes and Depends packages, and the BuiltVersion is incremented by a minor version number.
    "Packages: plyr,zoo,caret,forecast"
    "Built: TERR 6.0.0; 2020-10-10 15:18:00 PDT"
    "BuiltFile: MyServerSPK.spk"
    "BuiltName: Approved CRAN Packages"
    "        Windows b8bfb095"
    "BuiltId: b8bfb095-a6e6-49ac-a6347-c41c22b965fa"
    "BuiltVersion: 1.1.0.0"
    "BuiltPackages: KernSmooth (>=2.23-17),MASS (>=7.3-51.6),Matrix"
    "        (>=1.2-18),ModelMetrics (>=1.2.2.2),R6 (>=2.4.1),RColorBrewer"
    "        (>=1.1-2),Rcpp (>=1.0.4.6),SQUAREM (>=2020.3),TTR"
    "        (>=0.23-6),assertthat (>=0.2.1),caret (>=6.0-86),class"
    "        (>=7.3-17),cli (>=2.0.2),codetools (>=0.2-16),colorspace"
    "        (>=1.4-1),crayon (>=1.3.4),curl (>=4.3),data.table"
    "        (>=1.12.8),digest (>=0.6.25),dplyr (>=1.0.0),ellipsis"
    "        (>=0.3.1),fansi (>=0.4.1),farver (>=2.0.3),foreach"
    "        (>=1.5.0),forecast (>=8.12),fracdiff (>=1.5-1),generics"
    "        (>=0.0.2),ggplot2 (>=3.3.1),glue (>=1.4.1),gower"
    "        (>=0.2.1),gtable (>=0.3.0),ipred (>=0.9-9),isoband"
    "        (>=0.2.1),iterators (>=1.0.12),labeling (>=0.3),lattice"
    "        (>=0.20-41),lava (>=1.6.7),lifecycle (>=0.2.0),lmtest"
    "        (>=0.9-37),lubridate (>=1.7.8),magrittr (>=1.5),mgcv"
    "        (>=1.8-31),munsell (>=0.5.0),nlme (>=3.1-148),nnet"
    "        (>=7.3-14),numDeriv (>=2016.8-1.1),pROC (>=1.16.2),pillar"
    "        (>=1.4.4),pkgconfig (>=2.0.3),plyr (>=1.8.6),prodlim"
    "        (>=2019.11.13),purrr (>=0.3.4),quadprog (>=1.5-8),quantmod"
    "        (>=0.4.17),recipes (>=0.1.12),reshape2 (>=1.4.4),rlang"
    "        (>=0.4.6),rpart (>=4.1-15),scales (>=1.1.1),stringi"
    "        (>=1.4.6),stringr (>=1.4.0),survival (>=3.1-12),tibble"
    "        (>=3.0.1),tidyr (>=1.1.0),tidyselect (>=1.1.0),timeDate"
    "        (>=3043.102),tseries (>=0.10-47),urca (>=1.3-0),utf8"
    "        (>=1.1.4),vctrs (>=0.3.0),viridisLite (>=0.3.0),withr"
    "        (>=2.2.0),xts (>=0.12-0),zoo (>=1.8-8)"

    The SPK is ready to be placed in the Spotfire Server deployment area.

  6. Open a browser window and log in to Spotfire Server as the administrator.
  7. Click Deployments & Packages.
  8. Under Software Packages, click Add Packages.
    The Add packages dialog box is displayed.
  9. Browse to the location of the new SPK file, and then select it to add it.
  10. Validate the area, and then save the server page.
  11. Confirm updating the node if you are prompted to do so.

Result

The packages are added to the Spotfire Server node manager where the TERR service is deployed. They are ready to use in a visualization published for users of the Spotfire Web Player.

If you already installed the TERR service to your node manager, you must upgrade the service for the newly-installed packages to be deployed.

Related concepts