Load an estimated R model into Spotfire

We have written an R scripts that loads an estimated R model and given some inputs parameters returns a forecast.

To load the estimated model the scripts change the directory to the folder where the model is stored which is located on the server where the Statistics Services and the open source R engine we are using are both installed.

Since we are using R 3.4.4. we saved the model using save(model, filename = 'mymodel.rda') and to load the model we use load(filename = 'mymodel.rda').

The problem is that the Spotfire return the following error:

TIBCO Spotfire Statistics Services returned an error: 'load(file = "model.rda") : bad restore file magic number (file may be corrupted) -- no data loaded'.

   at Spotfire.Dxp.Data.DataFunctions.Executors.RemoteFunctionClient.OnExecuting()

   at Spotfire.Dxp.Data.DataFunctions.Executors.AbstractFunctionClient.<RunFunction>d__31.MoveNext()

   at Spotfire.Dxp.Data.DataFunctions.Executors.SPlusFunctionExecutor.<ExecuteFunction>d__12.MoveNext()

   at Spotfire.Dxp.Data.DataFunctions.DataFunctionExecutorService.<ExecuteFunction>d__3.MoveNext()

and the following warning:

file 'model.rda' has magic number 'RDX3'

  Use of save versions prior to 2 is deprecated

The configuration we are currently running is the following one:

Spotfire 10.2

Statistics Service 7.10

R used as the Sptofire engine


Thank you