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?

2
  • 'when I save it as "Rexec"' You lost me there. Commented Aug 10, 2016 at 6: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 - 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. Commented Aug 10, 2016 at 6:20

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

It is better to copy your edits to the answer here in stead of referring to them in your question.
Hi Paul, ok will do that next time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.