1

The simplified code of my R script is:

library(jsonlite)

function_name <- function(data.json)
{
 tmp <- jsonlite::fromJSON(data.json)
}

This runs perfect on my local PC. Then I build a package, upload the package to an ubuntu server and use the function within an OpenCPU/php environment. My package includes further functions stored in mathematic packages like randomForest, e1071, ... All mathematic packages work perfect, but the jsonlite::fromJSON(data.json) interrupts the programme. The same is true for the alternative package rjson. I don't known where to look for the reason of this strange error.

1 Answers1

0

First, be sure that jsonlite is installed in your Ubuntu server and opencpu can run it

Add the package that you need to the DESCRIPTION file structure and delete the library(jsonlite) part of code of your script.

function_name <- function(data.json) {
  tmp <- fromJSON(data.json)
}

I suggest to use Roxygen2 for import and exports functions depending of your needs

You can read about that and learn how to make the structure of a package in the online book R packages by Hadley Wickham

  • I controlled everything and did not find the error. Now a wrote a simple example to have a better look on the problem. Please see my further question: php guzzle OpenCPU POST request for a simple R package function stucks during execution – Werner Lechner Apr 03 '19 at 10:30