Creating an SPK to put a CRAN Package on Spotfire Server

By running a few lines of TERR code, you can create a Spotfire SPK that you can deploy to Spotfire Server for use by 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 creating an SPK containing two packages by downloading the packages, and then creating the Debian Control File (DCF) that specifies the package contents.

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

  • Review the SPK information in this Help.
  • You must have access to the TERR console, version 4.5 or later.
  • 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 include in the Spotfire SPK.
    This example shows installing 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.
    install.packages(c("plyr","zoo"))
    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. In the TERR console, generate a list file.
    In this example, we create the Debian Control File (DCF), which is a list file that contains the two sample packages.
    writeLines("Packages: plyr,zoo", "ServerSPK.dcf")
    The file ServerSPK.dcf contains one line: "Packages: plyr,zoo". (Make a note of the file location.)
  3. Load the library that contains the functions to create the SPK for Spotfire Server.
    library(SpotfireSPK)
  4. In the TERR console, call the function that creates the SPK, and pass in the name of the DCF you created, and then add the packages to an SPK named ServerSPK.spk.
    buildServerSPK("ServerSPK.dcf", "ServerSPK.spk")
    The Spotfire package file is created, and the file ServerSPK.dcf now contains the information similar to the following:
    "Packages: plyr,zoo"
    "Built: TERR 6.0.0; 2020-10-09 16:18:11 PDT"
    "BuiltFile: ServerSPK.spk"
    "BuiltName: TIBCO Enterprise Runtime for R Packages for Spotfire Server"
    "        Windows b8bfb095"
    "BuiltId: b8bfb095-a6e6-49ac-a634-c41c22b965fa"
    "BuiltVersion: 1.0.0.0"
    "BuiltPackages: Rcpp (>=1.0.1),lattice (>=0.20-38),plyr (>=1.8.6),zoo"
    "        (>=1.8-8)"
    Note: The BuiltVersion is always 1.0.0.0 when you create the DCF using TERR, and then to create an SPK, unless you specify a different version in the function call. See Spotfire SPK versioning for more information.

    The SPK is ready to be placed in the Spotfire Server deployment area. Make a note of its location.

  5. Open a browser window and log in to Spotfire Server as the administrator.
  6. Click Deployments & Packages.
  7. Under Software Packages, click Add Packages.
    The Add packages dialog box is displayed.
  8. Browse to the location of the new SPK file, and then select it to add it.
  9. Validate the area, and then save the server page.
  10. 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