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.
If you run an R script in batch mode (
R CMD BATCH
) the "interactive flag" is set tofalse
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:
If you run this script with
You will find the result
FALSE
in the out.txt file, if you run it withYou will see a
TRUE
(so use the last command line as solution - note: without CMD).