Lor*_*nti 2 dialog r messagebox
我们怎样才能在R中设计一个对话框?
在我看来,我有一些东西,其中显示警报消息或我们可以写一个值,然后单击一个按钮,它执行一些计算...是否可能在R工作区内?
这样的事情应该有效
library("tcltk")
button <- tkmessageBox(title='Message',message='Error x!',type='ok')
button <- tclvalue(button)
if(button == 'ok'){
#do something
}
Run Code Online (Sandbox Code Playgroud)
小智 6
winDialog 也有效:
library(utils)
answer<-winDialog("yesno", "was the suggestion useful?")
if (answer=='YES') {print('good!')} else {print('sorry')}
Run Code Online (Sandbox Code Playgroud)
只需尝试复制完整代码并将其粘贴到您的 R 控制台:将出现一个对话框,并根据您单击的答案显示最终输出(“好!”或“抱歉”)。