Spotfire® Service for R Installation and Administration

Creating an SPK to put a CRAN Package on Spotfire Server

By running a few lines of R code, you can create a Spotfire SPK that you can deploy to Spotfire Server for use by the Spotfire web clients.

About this task

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 R console.

You must use the same version of R that is running in the R Service on the node manager. This version of R must be a supported version, as listed in the System Requirements.

Before you begin

  • Review the SPK information in this Help.
  • You must have access to the R console.
  • 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 Windows servers, if you are creating the SPK from the R console, you must have a ZIP installation on the computer where you create the SPK.

Procedure

  1. From the R console, set the library path.
    .libPaths(c(.libPaths(), "<NM_HOME>/services/<path-to-spotfire-service-for-r>/library/<ver>"))
  2. From the R console, install the packages you want to include in the Spotfire SPK.
    This example shows installing two packages. The function that builds the SPK includes all Includes and Depends packages in the SPK.
    install.packages(c("dplyr","zoo"))
  3. In the R 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: dplyr,zoo", "ServerSPK.dcf")
    The file ServerSPK.dcf contains one line: "Packages: plyr,zoo". (Make a note of the file location.)
  4. Load the library that contains the functions to create the SPK for Spotfire Server.
    library(SpotfireSPK)
  5. In the R 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: dplyr,zoo
    Built: Spotfire Service for R <ver>; 2023-02-27 17:17:48 PST
    BuiltFile: ServerSPK.spk
    BuiltName: Spotfire Service for R Packages for Spotfire Server
            Windows 2116732a
    BuiltId: 2116732a-306b-48e1-9a66-da12286a44ce
    BuiltVersion: 1.0.0.0
    BuiltPackages: R6 (>=2.4.1),assertthat (>=0.2.1),cli (>=2.1.0),crayon
            (>=1.3.4),digest (>=0.6.25),dplyr (>=1.0.2),ellipsis
            (>=0.3.1),fansi (>=0.4.1),generics (>=0.0.2),glue
            (>=1.4.2),lattice (>=0.20-41),lifecycle (>=0.2.0),magrittr
            (>=1.5),pillar (>=1.4.6),pkgconfig (>=2.0.3),purrr
            (>=0.3.4),rlang (>=0.4.8),tibble (>=3.0.4),tidyselect
            (>=1.1.0),utf8 (>=1.1.4),vctrs (>=0.3.4),zoo (>=1.8-8)
    Note: The BuiltVersion is always 1.0.0.0 when you create the DCF using R, 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.

  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 and click Open.
  10. Click Upload.
  11. Click Save area to save the deployment area.

Results

The packages are added to the Spotfire Server node manager where the Spotfire Service for R is deployed. They are ready to use in a visualization published for Spotfire web client users.

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