Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Designing dialog box in R

How can we a design a dialog box in R?

In my mind I have something in which an alert message is displayed or where we can write a certain value and then clicking a button it performs some computation... is that possible within the R workspace?

like image 902
Lorenzo Rigamonti Avatar asked Dec 07 '22 09:12

Lorenzo Rigamonti


2 Answers

Something like this should work

library("tcltk")
button <- tkmessageBox(title='Message',message='Error x!',type='ok')
button <- tclvalue(button)
if(button == 'ok'){
  #do something
}
like image 187
Gx1sptDTDa Avatar answered Jan 02 '23 15:01

Gx1sptDTDa


winDialog also works:

library(utils)
answer<-winDialog("yesno", "was the suggestion useful?")
if (answer=='YES') {print('good!')} else {print('sorry')}

Just try to copy the full code and paste it into your R console: a dialog box will come out and a final output ('good!' or 'sorry') will appear depending on the answer you click.

like image 32
Fabio Natalini Avatar answered Jan 02 '23 15:01

Fabio Natalini