# Removing CRAN Packages from an existing SPK to put on Spotfire Server

By editing the DCF and then running a few lines of TERR code, you can remove packages from a Spotfire SPK that you can deploy to Spotfire Server for use by the TERR service and Spotfire web client users.

## 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 removing packages from an existing SPK, and then uploading the resulting SPK to the Spotfire Server.

Perform this task from the TERR console. Always use the version of TERR that is listed as supported in the System Requirements.

Note: On Windows, start the TERR console available from the Tools menu in Spotfire Analyst

## Before you begin

- Review the SPK information in this Help.
- You must have access to the TERR 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.

## Procedure

1. Open the DCF containing the original packages in a text editor.
2. Find the line containing the package names.
   `"Packages: plyr,zoo,caret,forecast"`.
3. Remove the package names from the list, and then save the DCF.
   Do not change any other lines in the DCF.
   `"Packages: forecast"`.
4. 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 & 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 built file.

       buildServerSPK("ServerSPK.dcf", "ServerSPK.spk", spkName="Approved CRAN Packages")

   The Spotfire package file is created, and the file ServerSPK.dcf now contains only the packages you retained in the file, as well as all Includes and Depends packages, and the BuiltVersion is incremented by a major version number.

       "Packages: forecast"
       "TERR service <ver>; 2023-02-27 17:22:42 PST"
       "BuiltFile: MyServerSPK.spk"
       "BuiltName: Approved CRAN Packages"
       "        Windows b8bfb095"
       "BuiltId: b8bfb095-a6e6-49ac-a6347-c41c22b965fa"
       "BuiltVersion: 2.0.0.0"
       "BuiltPackages: MASS (>=7.3-51.6),Matrix (>=1.2-18),R6"
       "        (>=2.4.1),RColorBrewer (>=1.1-2),Rcpp (>=1.0.4.6),TTR"
       "        (>=0.23-6),assertthat (>=0.2.1),cli (>=2.0.2),colorspace"
       "        (>=1.4-1),crayon (>=1.3.4),curl (>=4.3),digest"
       "        (>=0.6.25),ellipsis (>=0.3.1),fansi (>=0.4.1),farver"
       "        (>=2.0.3),forecast (>=8.12),fracdiff (>=1.5-1),ggplot2"
       "        (>=3.3.1),glue (>=1.4.1),gtable (>=0.3.0),isoband"
       "        (>=0.2.1),labeling (>=0.3),lattice (>=0.20-41),lifecycle"
       "        (>=0.2.0),lmtest (>=0.9-37),magrittr (>=1.5),mgcv"
       "        (>=1.8-31),munsell (>=0.5.0),nlme (>=3.1-148),nnet"
       "        (>=7.3-14),pillar (>=1.4.4),pkgconfig (>=2.0.3),quadprog"
       "        (>=1.5-8),quantmod (>=0.4.17),rlang (>=0.4.6),scales"
       "        (>=1.1.1),tibble (>=3.0.1),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.

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

## Results

The packages are added to the Spotfire Server node manager where the TERR service is deployed. They are ready for use in analyses to be opened with the Spotfire web client.

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