gWidgetstcltk - 警告消息

时间:2014-03-06 23:16:44

标签: r rstudio

我正在使用包gWidgetstcltk来创建一个可以操作绘图的GUI。它工作正常,但我收到几条警告信息。我必须使用这个软件包作为创建交互式图表的方法,因此我将被问到这些警告的含义。有没有办法可以摆脱它们,或者有人可以解释是什么导致它们的?

代码如下,我收到的警告信息是:

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))

0 个答案:

没有答案