R Report Error marcia hon  2018-06-08 10:19
Status: Closed
 

Hello,

I get the following error when trying to run an R Report:

Error executing command
javax.script.ScriptException: javax.script.ScriptException: An error occurred when running the script 'script.R', exit code: 1).

My script is the following:

knitr::opts_chunk$set(echo=FALSE, cache=FALSE, comment=FALSE, comments = "", warning=FALSE, eval = TRUE, encoding = "native.enc")
#knitr::opts_chunk$get();
knitr::pandoc('script.Rmd', format='html')
currentdir <- getwd()
assign("html_filename", paste(currentdir, "/script.html", sep=""))
assign("out_filename", paste("/nip/NRG_Samples/@files/Reports/GenotypingResults_CNR1rs2023239_DRD3rs6280/Report_GenotypingResults_CNR1rs2023239_DRD3rs6280_", format(Sys.time(), "%Y-%m-%d_%H:%M:%S"), ".html", sep=""))

#list.files(path = ".", pattern = NULL, all.files = FALSE,
#           full.names = FALSE, recursive = FALSE,
#           ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)

file.copy(from = html_filename, to = out_filename)

system("rm script.* *.tsv")
#system("rm cache/*.*")
#list.files(path = ".", pattern = NULL, all.files = FALSE,
#           full.names = FALSE, recursive = FALSE,
#           ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)

<html>...</html>

I look forward to your suggestions.

Thanks,
Marcia

 
 
Will Holtz responded:  2018-06-08 10:39

Hi Marcia,

If the last line of your script does not remove any files (because nothing matches your file globs), then that system() command will return 1. I'm guessing this results in the exit code for the whole script to be 1, and this gets interpreted as an error. You could try appending system('echo') to the end of your script and see if the behavior changes.

-Wil

 
marcia hon responded:  2018-06-08 10:45
I removed it, and the error has changed:


Error executing command
javax.script.ScriptException: javax.script.ScriptException: An error occurred when running the script 'script.R', exit code: 1).


processing file: /usr/local/apache-tomcat-8.0.38/temp/reports_temp/.../Report_db_46/cached/script.Rmd

  |
  | | 0%
  |
  |......... | 14%
label: labkey (with options)
List of 1
 $ echo: logi FALSE


  |
  |................... | 29%
label: setup (with options)
List of 8
 $ echo : logi FALSE
 $ cache : logi TRUE
 $ results : chr "hide"
 $ warning : logi FALSE
 $ comment : logi FALSE
 $ message : logi FALSE
 $ encoding: chr "UTF-8"
 $ comments: chr ""


  |
  |............................ | 43%
  ordinary text without R code


  |
  |..................................... | 57%
label: unnamed-chunk-1 (with options)
List of 8
 $ echo : logi FALSE
 $ cache : logi FALSE
 $ results : chr "hide"
 $ warning : logi FALSE
 $ comment : logi FALSE
 $ message : logi FALSE
 $ encoding: chr "UTF-8"
 $ comments: chr ""


  |
  |.............................................. | 71%
   inline R code fragments

Quitting from lines 38-95 (/usr/local/apache-tomcat-8.0.38/temp/reports_temp/.../Report_db_46/cached/script.Rmd)
Error in eval(expr, envir, enclos) : object 'labkey.data' not found
Calls: knit2html ... inline_exec -> hook_eval -> withVisible -> eval -> eval
In addition: Warning message:
In readLines(con) :
  incomplete final line found on '/usr/local/apache-tomcat-8.0.38/temp/reports_temp/.../Report_db_46/cached/script.Rmd'

Execution halted
 
Jon (LabKey DevOps) responded:  2018-06-22 18:58
Hi Marcia,

We unfortunately are unable to troubleshoot your R script fully due to our Support Guidelines as mentioned here:

https://www.labkey.org/home/Support/project-begin.view?

What I would recommend doing is to try and break down your script into smaller functional pieces and systematically start combining them until you have a fully functioning script.

Regards,

Jon
 
dabaker3 responded:  2018-11-02 06:32
I have experienced a similar error message to : Error in eval(expr, envir, enclos) : object 'labkey.data' not found

This happened to me when a data grid associated with the report had no data selected, or the selected data has since been deleted. Try selecting data and see if the error resolves.