找不到功能“eventReactive”

时间:2015-09-01 08:58:31

标签: html r shiny rstudio

当我在Ubuntu中运行应用程序时它运行得很好但是当我在Mac OSX上运行时,事情(如按钮)没有对齐,一段时间后我收到以下错误:

> shiny::runApp()
Loading required package: shiny

Listening on http://127.0.0.1:7240
Loading required package: lattice
Loading required package: ggplot2
data.table 1.8.10  For help type: help("data.table")
Error in (structure(function (input, output)  : 
  could not find function "eventReactive"
ERROR: [on_request_read] connection reset by peer

以下是代码的一部分:

trainres <- eventReactive(input$buttontrain, {
    thisfds = list(); singtrain = NULL; singtest = NULL
    thiskfkds = list(); multtrain = NULL; multtest = NULL
    yvectr = NULL; yvects = NULL; predvectr = NULL; predvects = NULL
    tim = 0.0
    if(input$dbterm == "Multi table") {
      thiskfkds = append(thiskfkds, KFKD(EntCol=input$fk1, AttCol=input$pk1, UseFK=input$usefk1))
      if(!is.null(input$fk2)) {
        thiskfkds = append(thiskfkds, KFKD(EntCol=input$fk2, AttCol=input$pk2, UseFK=input$usefk2))
      }
      if(!is.null(input$fk3)) {
        thiskfkds = append(thiskfkds, KFKD(EntCol=input$fk3, AttCol=input$pk3, UseFK=input$usefk3))
      }
      cat("KFKDs:\n")
      print(thiskfkds)
      multtrain = switch(input$dataset,
                         "Walmart" = MultData(Target=as.data.frame(WStr[,1]), EntTable=WStr[,-1], AttTables=list(WR1, WR2), KFKDs=thiskfkds),
                         "Walmart (R)" = MultData(Target=as.data.frame(DWStr[,1]), EntTable=DWStr[,-1], AttTables=list(DWR1, DWR2), KFKDs=thiskfkds),
                         "Yelp" = MultData(Target=as.data.frame(YStr[,1]), EntTable=YStr[,-1], AttTables=list(YR1, YR2), KFKDs=thiskfkds),
                         "Yelp (R)" = MultData(Target=as.data.frame(DYStr[,1]), EntTable=DYStr[,-1], AttTables=list(DYR1, DYR2), KFKDs=thiskfkds),
                         "Expedia" = MultData(Target=as.data.frame(EStr[,1]), EntTable=EStr[,-1], AttTables=list(ER1, ER2), KFKDs=thiskfkds),
                         "Expedia (R)" = MultData(Target=as.data.frame(DEStr[,1]), EntTable=DEStr[,-1], AttTables=list(DER1, DER2), KFKDs=thiskfkds),
                         "Flights" = MultData(Target=as.data.frame(FStr[,1]), EntTable=FStr[,-1], AttTables=list(FR1, FR2, FR3), KFKDs=thiskfkds),
                         "Flights (R)" = MultData(Target=as.data.frame(DFStr[,1]), EntTable=DFStr[,-1], AttTables=list(DFR1, DFR2, DFR3), KFKDs=thiskfkds)
      )

以下是运行后应用的外观: enter image description here

这是ui.R中的代码:

library(shiny)
library(caret)

shinyUI(fluidPage(
    list(tags$head(HTML('<h4><table><tr><td rowspan="2"><img src="http://umark.wisc.edu/brand/templates-and-downloads/downloads/print/UWCrest_4c.jpg" 
          border="0" style="padding-right:10px" width="34" height="40" alt="UW-Madison Database Group"/> 
          </td><td><b>Santoku</b></td></tr><tr><td>University of Wisconsin-Madison Database Group</td></tr></table></h4>'))),
    sidebarLayout(
      sidebarPanel(width = 6,
                   wellPanel(fluidRow(column(6, radioButtons("dbterm", "Database Type", c("Multi table", "Single table"))),
                                      column(6, selectInput("dataset", "Load Dataset", c("Walmart", "Walmart (R)", "Yelp", "Yelp (R)", "Expedia",
                                                                                         "Expedia (R)", "Flights", "Flights (R)")))),
                             uiOutput("uideps")),
                   wellPanel(fluidRow(column(6, radioButtons("mlalgo", "ML Model:", c("Logistic Regression" = "lr", "Naive Bayes" = "nb",
                                                                                          "TAN" = "tan", "Decision Tree" = "dt"))),
                                      column(6, uiOutput("uimlpt"))),
                             fluidRow(div(class="padding2", column(3, checkboxInput("checkcv", "Validate", TRUE))),
                                      div(class="padding3", column(2, actionButton("buttontrain", "Learning"))),
                                      div(class="padding4", column(3, actionButton("buttonfe", "Feature Exploration")))))
                   ),
      mainPanel(width = 6,
                tabsetPanel(
                  tabPanel("Single Learning", verbatimTextOutput("trainreso")), 
                  tabPanel("Feature Exploration", plotOutput("feplotso"))
                  #tabPanel("Wiki", verbatimTextOutput("Wiki")),
                  #tabPanel("Analysis", tableOutput("plots"))
                  )
                )
      )#end sidebarLayout
))#end main

1 个答案:

答案 0 :(得分:0)

当前版本为shiny 0.12.2,此版本中有一个名为eventReactive的函数。要快速更新,您可以使用代码;

install.packages(shiny)