gWidgets GUI cannot display when called with R CMD BATCH

匆匆过客 提交于 2019-12-02 04:47:23

问题


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.


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!