To successfully use an R script tool as a geoprocessing service, the server needs to be set up with R to run the service successfully.
Deployment mode
Regardless of your deployment mode, all servers with ArcGIS Server will need to be set up individually. For example, if there is a web adapter in front of a cluster of ArcGIS Server machines, each individual machine with ArcGIS Server will need to be configured.
Installation of R
On the server, install the latest R under the ArcGIS Server account. The recommended version is Microsoft R 64 bit version. For instructions about the installation, please refer to Microsoft R Application Network.
Install R as an administrator
If you are installing R as an administrator, ensure that the installation directory can be accessed by the ArcGIS Server account. In most cases, an ArcGIS Server account will not have write access to the default installation directory (C:\Program Files)..
Install as the ArcGIS Server account user
An installation-free version is an alternative, if installation on a server machine is restricted or administrator privilege cannot be granted. You can install R on any machine where you have administrator rights, and copy the installed files to the server. After that, make sure to create a RIntegration.conf file as described below.
Packages consideration (Server internet access)
In case the script require additional packages, the ArcGIS Server account needs to be able to install the package into the R directory. Also, an internet connection with access to the CRAN (the Comprehensive R Archive Network) is needed for the packages to be installed successfully. If the server doesn't have internet access, you will have to install all the packages and their dependencies an R script may need into R on the ArcGIS Server machine manually.
Installation of arcgis binding
1. Download the latest version of arcgisbinding from the GitHub Page.
2. Open R on the ArcGIS Server machine by launching \[R install directory]\R-[version]\bin\x64\Rgui.exe.
3. In the top menu, choose Packages, select Install packages from local files, and point to the downloaded zip file.
Configuration File Setup
In the user folder of ArcGIS Server Account at ..\[ArcGIS Server Account User]\AppData\Local\ESRI, create a file named RIntegration.conf. In the configuration file, add R_HOME=[R Installation directory] in the file.
For example, in C:\Users\arcgis\AppData\Local\ESRI\RIntegration.conf, add the following: R_HOME=C:\R_Installation\R-3.5.0
Known Limitations
Running scripts within R on a server machine
If you start R on the server machine and run the code below, there will be an error. However, it will not affect geoprocessing services running and executing with R scripts.
Sample code will result an error.
> library(arcgisbinding)
> arc.check_product()
Scripting leveraging distributed environment
If your scripts are using more sophisticated data science functions in a distributed environment, or using R_SERVER, some special configurations will need to be set up.