3

I'm using the package gWidgetstcltk to create a GUI that can manipulate a plot. It works fine, but I get several warning messages. I have to present the use of this package as a means of creating an interactive plot so I'm going to be asked what these warnings mean. Is there a way I can get rid of them or can someone explain what causes them?

The code is below and the warning messages I receive are:

Warning in str.default(val) : 'str.default': 'le' is NA, so taken as 0
Warning in str.default(obj, ...) :
  'str.default': 'le' is NA, so taken as 0
Error in envRefInferField(x, what, getClass(class(x)), selfEnv) : 
  ‘no_items’ is not a valid field or method name for reference class “SpinButton”

# Install and load required package
# install.packages(gWidgetstcltk)
library(gWidgetstcltk)

# Create the handler (function that the GUI will run when options are selected)
p <- function(...) {
  # svalue will grab the value the variable has been set too
  # Subsets based on year if all years has not been selected
  if (svalue(all.yrs)=="FALSE") {
    df<-subset(d2,d2$Year==svalue(yr))
  } else {
    df<-d2
  }

  # Subset by country if all is not selected
  if (svalue(cntry) != "All") {
    df<-subset(df,df$CntryName==svalue(cntry))
  }

  # Create the plot
  plot<-ggplot(df,aes(x=Expectancy,y=Fertility))+
    geom_blank()+
    scale_x_continuous(limits=c(15,90))+
    scale_y_continuous(limits=c(0,10))+
    scale_size_area(max_size=10)+
    theme_bw()

  # Add the geom based on selection
  if (svalue(type)=="Points") {
    plot<-plot+geom_point(aes(size=Population,colour=Region),alpha=0.8)
  } else if (svalue(type)=="Smooth") {
    plot<-plot+geom_smooth(aes(colour=Region),method="auto",alpha=0.8,size=2)
  }
  print(plot)
}

# Create window and add widgets
win_ctrls <- gwindow("Plot controls")
tbl = glayout(container=win_ctrls)
tbl[1,1]<-"Year: "
tbl[1,2] <- (yr <- gspinbutton(from = 1960, to= 2011, by=1, value = 1960,container = tbl,handler=p))
tbl[2,1]<-"All Years? "
tbl[2,2]<- (all.yrs<-gcheckbox("Yes", container=tbl,handler=p))
tbl[3,1]<-"Country: "
tbl[3,2]<-(cntry<-gcombobox(c("All",unique(as.character(d2$CntryName))), editable=FALSE, container=tbl, handler=p))
tbl[4,1]<-"Plot Type: "
tbl[4,2,expand=TRUE]<-(type<-gradio(c("Points","Smooth"),selected=1,index=FALSE,horizontal=TRUE,container=tbl,handler=p))
2
  • 1
    It appears the problem is related to Rstudio. If I run it from the console I get no errors. Mar 7, 2014 at 2:30
  • I guess if those are the only warnings you're getting, it's no foul to suppress warnings globally just for that session. Oct 9, 2014 at 4:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.