# Uploading a Package to Spotfire Statistics Services From a Repository

If you have access to the internet from your installation of Spotfire Statistics Services, you can log on to the server and install packages directly.

## About this task

Perform this task on the computer where Spotfire Statistics Services is installed.
Note: If your Spotfire Statistics Services installation is a cluster, you must perform this task on every computer in the cluster.

## Before you begin

You must be able to log on with administrative credentials to the server where Spotfire Statistics Services is installed.

You must have built the package archive or downloaded a compatible package from a trusted web site or package repository.

- Note:

  The repositories contain binary packages (for Windows) and source packages (for Linux and Windows). You can easily install most binary and source packages in TERR. If you have problems building from source, then build the packages using open-source R before installing them into TERR. Note that TERR does not build binary packages from source packages that contain Java source code.

  Platform | Package type | Notes
  --- | --- | ---
  Linux, Windows | Binary | Call `install.packages(pkgname)`. TERR installs the binary package into your specified package directory.
  Linux | Source; no Java code, no C/C++ or Fortran code | Call `install.packages(pkgname)`. TERR builds the source package into a binary package and installs it into your specified package directory.
  Linux, Windows | Source; C/C++ or Fortran code (no Java code) | Note: On Windows, first you must install the Rtools utilities package, which is maintained by Duncan Murdoch, and then update your PATH to specify the location of the utilities. If you have not already done so, install the package rinclude by calling `install.packages(rinclude)` Call `install.packages(pkgname)`. Note: See Installation Options for Packages for information on repositories accessed by `install.packages`. TERR builds the source package into a binary package and installs it into your specified package directory. If the package does not build and install, then try building it with open-source R, and then installing the binary as described here.
  Linux | Source; Java code | Build the package using open-source R tools for building packages from source. The tools compile the source code to create the binary package. Call `install.packages(pkgname)`.

  See the help for `install.packages(pkgname)` for more information.

  Due to changes in open-source R version 3.5 and resulting compatibility changes in TERR 5.0, packages that are built with a version of TERR prior to 5.0 must be rebuilt.
  - To install a binary package from a repository, always call `install.packages(pkgname)` from TERR. The `install.packages` function finds the correct binary version in the repository for your version of TERR. Manually downloading the binary package from CRAN can result in errors when you use it with TERR.
  - To install a package from source, try installing it first with TERR (with `install.packages` in TERR or with `TERR CMD INSTALL` from a command line).
  - To install a package from source that you cannot build with TERR, install the package with the version of open-source R tested with TERR.

  Spotfire Statistics Services accepts .zip archives (Microsoft Windows servers only) or tar.gz archives (Linux servers only).

- If you plan to download an R package from CRAN to run on the TERR engine, we recommend that you check the package compatibility list for the version of TERR on your installation of Spotfire Statistics Services, and test the package with the version of TERR that is in your installation of Spotfire Statistics Services. See the Documentation page for TERR for more information.

## Procedure

1. Log on with administrator credentials to the computer where Spotfire Statistics Services is installed.
   If you do not have administrative credentials, ask your server administrator to help you.
2. Open the bin directory of the server's engine.
   This path should look like SPSERVER_HOME/engines/eng/bin where SPSERVER_HOME is the installation and server context, and eng is the language engine, such as open-source R or TERR.
   Windows example: C:\Program Files\TIBCO\statsvcs1231\TERRServer\engines\Terr\bin
3. Right-click the language engine executable, and from the menu, click Run as administrator.
   A console for the language starts.
4. At the console command prompt, type the command `install.packages("pkgname")`, where `pkgname` is the package you want to install.
   If your installation of Spotfire Statistics Services is configured to be able to install packages from the internet, then `install.packages()` installs from Posit. If you want to install a package from another repository, such as an in-house package repository, provide the path using the `repos` argument.
   Note: By default, Spotfire Statistics Services is configured to restrict access to file I/O, downloading from the internet, and any other operation that can be considered a potential malicious action. If your installation of Spotfire Statistics Services is not configured to be able to install packages from the internet, then see your system administrator for guidance on how to get the packages you need.
   Example: `install.packages("h2o")`
   The current version of the package and all of the packages it requires to work are downloaded and installed into the directory SPSERVER_HOME/engines/eng/library from the specified repository.

## What to do next

Validate the package upload.