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?
>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"