¿Cat() Call could be missing on Launch.R? at unexpected string in json at position 4
letrape opened this issue · comments
I've starting using this library for an android speed detection app wich requires to process the data with R.
I am exposing the result data trought an API, so the app can use the result.
Well first I have faced several problems to run my algorithm within Node.js some solutions was:
- install all libraries via Rscript inside the server console not vía needs (you must use install.package and specify a repo)
2)Check if Rscript is in the path and check if the lib folder for installing packages has write permissions in order to use Needs
- Install the latest Pull Requests, the master branch has some bugs, reviewing and installing the pull-request in this repo helped me a lot
Well finally I've get stucked on an error from node
ERROR:
unexpected string in json at position 4
It was because the return of the launch.R file was [1] "[35.636]" , where 35.363 is the result of my R algorithm.
I've tried with other results such as data frames and the result was the same [1] "[x1][x2]..."
The problem is that the double quotes are not a valid JSON format
then after hours of thinking, I've decided to call cat( ) function in the Launch.R file and all my problems gone
Replacing this line
do.call(toJSON, .e$out)
with:
output <- do.call(toJSON, .e$out)
cat(output)
My question is:
My workaround is correct? or Im missing something ?