I developed a analyzer with GUI (utilizing gWidgets package). Everything seems good when I run my code in R console or R studio, GUI can popup as exptected, 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.
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).
来源:https://stackoverflow.com/questions/18730175/gwidgets-gui-cannot-display-when-called-with-r-cmd-batch