0

I have created a script that works fine when I run it from Rstudio.

However, when I save it as "Rexec" and try to run it by double clicking, it only partially launches.

I get a navigate gui pop-up to the initial file location, but then nothing happens after that. The black box with various messages displays some quickfire messages and closes before i can see what happened.

I have run another, much bigger script this way and had no problems.

This script is distinct in that when I run it through RStudio, there are multiple interactive gui dialog pop-ups that require some input from me i.e. choose column headers with select.list or save file as png via using:

png.filename <- tclvalue(tkgetSaveFile(initialfile = "choose name.png",
                                       filetypes = "{ {PNG Files} {.png} }"))

How can I check what is causing the problem i.e. output an error log?

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
Alex M
  • 165
  • 1
  • 2
  • 15
  • 'when I save it as "Rexec"' You lost me there. – Roland Aug 10 '16 at 06:08
  • Apologies for my poor post. What I meant was that I save the R script as i.e. "foo_script.Rexec". I can then associate that file type as an executable like this - http://www.r-datacollection.com/blog/Making-R-files-executable/. Launching script is then just a matter of double clicking on "foo_script.Rexec". Please see my edit as I found examples of how to produce error log and then how to fix issue. – Alex M Aug 10 '16 at 06:20

1 Answers1

0

I found this example of how to get error log: Output error/warning log (txt file) when running R script under command line.

I just added these lines to my code as follows:

zz <- file("error_log.text", open="wt")
sink(zz, type="message")

....code chunk....

sink(type="message") 
close(zz)

This writes a text file to the directory containing "foo_script.Rexec" with some messages that contain the following:

Error in select.list(names(MQ.file.DF), multiple = TRUE, title = "Choose variables to remove",  : 
  select.list() cannot be used non-interactively
Execution halted

select.list() seems to be the issue, hence the process crashing.

Work around - I changed to using tk_select.list and that seems to sort the problem. Script runs without a crash. I kind of prefer select.list as it supports click and dragging of cursor to highlight multiple columns, whereas with tk_select.list you have to click one at a time. I'll take a few more clicks as long as it runs ok. I hope this helps someone with a similar issue.

Community
  • 1
  • 1
Alex M
  • 165
  • 1
  • 2
  • 15