Spotfire® Service for R Installation and Administration

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

By editing the DCF and then running a few lines of R code, you can add packages to a Spotfire SPK that you can deploy to Spotfire Server for use by the Spotfire Service for R and 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 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 R console. Always use the version of R that is listed as supported in the System Requirements.

Before you begin

  • You must have access to the R console.
  • 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.

Procedure

  1. From the R console, install the packages you want to add.
    This example shows adding two packages. The function that builds the SPK includes all Includes and Depends packages in the SPK.
    #example
    install.packages(c("caret,forecast"))
  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 R 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 & Packages list on Spotfire Server.
    The name of the SPK to display in the Deployments & Packages list is needed to differentiate the manually-edited file from the 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: Spotfire Service for R <ver>; 2023-02-27 17:19:25 PST
    "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 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 for use in analyses to be opened with the Spotfire web client.

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.