Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

work with the value from tkmessagebox in R

require(tcltk)
msgBox1 <- tkmessageBox(title = "Trial", message = "Run code?", icon = "info", type = "yesno")

msgBox1


if (msgBox1 == 'yes')
{
print('yesterday')
}

Error in msgBox1 == "yes" :
comparison (1) is possible only for atomic and list types

How can I access the yes/no value for comparison?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The value can be obtained with tclvalue:

if (tclvalue(msgBox1) == 'yes')
{
   print('yesterday')
 }
#[1] "yesterday"

Another option is to convert msgBox1 to character :

if (as.character(msgBox1) == 'yes')
{
   print('yesterday')
 }
#[1] "yesterday"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading