使用 R CMD BATCH 调用时,gWidgets GUI 无法显示 [英] gWidgets GUI cannot display when called with R CMD BATCH
问题描述
我开发了一个带有 GUI 的分析器(使用 gWidgets 包).当我在 R 控制台或 R Studio 中运行我的代码时,一切似乎都很好,GUI 可以按预期弹出,通过选择选项进行交互.
但是,我的经理对编码内容一无所知,他想要的是 click-N-run.所以我尝试使用 R CMD BATCH
创建 .bat
文件.
R CMD BATCH G:\Temp\dav\AB_Analyzer\MAINcode.r outputFile
当我运行 bat 文件时,没有任何东西弹出.
我可以知道我做错了什么吗?
感谢您的帮助.
如果在批处理模式下运行 R 脚本 (R CMD BATCH
),interactive flag"将设置为 false
可能触发此行为(无用户交互 = 不显示任何 GUI).
您可以使用 R 中的 interactive()
函数查询交互标志".
可能的解决方案:在命令行中添加--interactive
参数.
要测试他的行为,请创建一个包含以下内容的 R 脚本文件:
print(interactive())
如果你用
运行这个脚本R CMD BATCH --no-save --no-restore batch_test.R out.txt
你会在out.txt文件中找到结果FALSE
,如果你用
R --vanilla --interactive <批测试.R
您将看到 TRUE
(因此使用最后一个命令行作为解决方案 - 注意:没有 CMD).
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 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).
这篇关于使用 R CMD BATCH 调用时,gWidgets GUI 无法显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!