I am working on the r panel package. Now if i have a function that uses a radiogroup button, and if i attempt to run the function from inside the rpanel menu, i get this error:
Error in panel$intname : $ operator is invalid for atomic vectors However if i run the function per se i.e. not from inside the rpanel menu, but by calling it independently, the above error doesn't appear. Here is a simple example. Try running the whole code versus just running the add() function. The former results in the above error and the latter doesn't. install.packages(c("rpanel","tkrplot")) my.menu <- function(panel) { library(rpanel,tkrplot) if (panel$menu=="Add"){ add() } else panel } main.panel <- rp.control(title = "Main Menu",size=c(200,150)) rp.menu(panel = main.panel, var = menu, labels = list(list("Addition", "Add")), action = my.menu) # function to do adddition add <- function(){ my.draw <- function(panel) { if(panel$vals=="numbers"){ val<-as.numeric(panel$nmbr1)+as.numeric(panel$nmbr2) } else if(panel$vals=="strings"){ val <- paste(as.character(panel$nmbr1), "and" ,as.character(panel$nmbr2)) } plot(1:10, 1:10, type="n", xlab="", ylab="", axes=FALSE, frame = TRUE) text(5, 5, paste("Result: ", val),cex=1.4) panel } my.redraw <- function(panel) { rp.tkrreplot(panel, my.tkrplot) panel } my.panel <- rp.control(title = "Addition") rp.textentry(panel = my.panel, var = nmbr1, labels = "First: ", action = my.redraw, initval="100") rp.textentry(panel = my.panel, var = nmbr2, labels = "Second:", action = my.redraw, initval="200") rp.radiogroup(panel = my.panel, var = vals, values = c("numbers", "strings"), action = my.redraw, title = "Type") rp.tkrplot(panel = my.panel, name = my.tkrplot, plotfun = my.draw) } [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.