simeonyyyyyy
simeonyyyyyy

Reputation: 87

gWidgets GUI cannot display when called with R CMD BATCH

I developed an analyzer with GUI (utilizing gWidgets package). Everything seems good when I run my code in R console or R studio, GUI can popup as expected, interaction goes smoothly by choosing options.

However, my manager has no idea about coding stuff, and what he wants is click-N-run. So I tried to use R CMD BATCH to create .bat file.

R CMD BATCH G:\Temp\dav\AB_Analyzer\MAINcode.r outputFile

When I ran the bat file, there is nothing popping up.

May I know what I did wrong?

Thanks for any help.

Upvotes: 2

Views: 790

Answers (1)

R Yoda
R Yoda

Reputation: 8760

If you run an R script in batch mode (R CMD BATCH) the "interactive flag" is set to false which may trigger this behaviour (no user interaction = do not show any GUI).

You can query the "interactive flag" with the interactive() function in R.

Possible solution: Add the --interactive parameter to the command line.

To test his behaviour create an R script file with the following content:

print(interactive())

If you run this script with

R CMD BATCH --no-save --no-restore  batch_test.R out.txt

You will find the result FALSE in the out.txt file, if you run it with

R --vanilla --interactive  < batch_test.R

You will see a TRUE (so use the last command line as solution - note: without CMD).

Upvotes: 1

Related Questions