闪亮的编程错误:警告:sourceUTF8中的错误:堆栈跟踪(最里面的第一个):

时间:2017-02-17 01:32:59

标签: r shiny probability

我正在编写一个逻辑回归应用程序,其中包含几个条件面板,应根据用户选择的提示显示结果概率...但是当我运行应用程序时,页面无法加载,我收到错误喜欢:

  

在解析时听http://127.0.0.1:6497错误(文件,keep.source =   FALSE,srcfile = src,encoding = enc)输入172的意外结束:)   173:       ^警告:sourceUTF8出错:出错C:\ Users堆栈跟踪(最里面的第一个):       1:runApp

我应该在server.R中使用switch case吗?感谢。

    UI.R
    pageWithSidebar(

    # Application title
    headerPanel("Steadylosing NBA Probability Set (5200+ Observations)"),


        # Sidebar with conditional slider inputs 
        sidebarLayout(
    sidebarPanel(
      selectInput(
        "Occur",
        "Pick One Outcome to Predict:",
        choices = c(
          "TeamAWin",
          "BothTeamsAllow110+"
        )
      ),
      conditionalPanel(
        condition = "input.Occur == 'TeamAWin",
        sliderInput("aoff", "A's Offensive Rating", 90, 125, 100, .1),
        sliderInput("adef", "A's Defensive Rating", 90, 125, 100, .1),
        sliderInput("boff", "B's Offensive Rating", 90, 125, 100, .1),
        sliderInput("bdef", "B's Defensive Rating", 90, 125, 100, .1),
        selectInput("homecourt", "Homecourt, Yes or No?", choices = c(0, 1))
      ),
      conditionalPanel(
        condition = "input.Occur == 'BothTeamsAllow110+",
        sliderInput("aoff2", "A's Offensive Rating", 90, 125, 100, .1),
        sliderInput("adef2", "A's Defensive Rating", 90, 125, 100, .1),
        sliderInput("boff2", "B's Offensive Rating", 90, 125, 100, .1),
        sliderInput("bdef2", "B's Defensive Rating", 90, 125, 100, .1),
        selectInput("ot2", "Overtime, Yes or No?", choices = c(0, 1)),
        sliderInput("combpace2", "Combined Pace of the Two Teams", 170, 220,     200, .1)
      )

    ),

    # Show prediction values
      mainPanel(

      h2(textOutput("Prediction1")),

      h2(textOutput("Prediction2"))
  )




Server.R 
        shinyServer(function(input, output, session) {
  sliderValues <- reactive({

    # Compose data frame
    data.frame(
      Name = c("aoff", #TeamAoffrtg
               "adef", #TeamAdefrtg
               "boff", #TeamBoffrtg
               "bdef", #TeamBdefrtg
               "homecourt",
               "aoff2", #TeamAoffrtg
               "adef2", #TeamAdefrtg
               "boff2", #TeamBoffrtg
               "bdef2", #TeamBdefrtg
               "ot2", #Overtime
               "combpace2"),

      Value = as.double(c(input$aoff,
                          input$adef,
                          input$boff,
                          input$bdef,
                          input$homecourt,input$aoff2,
                          input$adef2,
                          input$boff2,
                          input$bdef2,
                          input$ot2,
                          input$combpace2)),
      stringsAsFactors=FALSE)

  } )

  function1 <- function(aoff,adef,boff,bdef,homecourt) {
    100*((exp(-1.9418+.1572*aoff-.144*adef-.139*boff+.1414*bdef+.4341*homecourt))/(1+exp(-1.9418+.1572*aoff-.144*adef-.139*boff+.1414*bdef+.4341*homecourt)))
  }
  function2 <- function(aoff2,adef,boff,bdef,ot2,combpace2) {
    100*((exp(-74.6058-.0788*aoff2+.0874*adef+.0795*boff-.09166*bdef+2.8053*ot2+.1897*combpace2))/(1+exp(-74.6058-.0788*aoff2+.0874*adef+.0795*boff-.09166*bdef+2.8053*ot2+.1897*combpace2)))
  }
  output$Prediction1 <- renderText({
    predtype <- input$Occur
    if (predtype == "TeamAWin"){
    c(round(function1((input$aoff),(input$adef),(input$boff),(input$bdef),(input$homecourt)),4),"%")

    }
    })
  output$Prediction2 <- renderText({  predtype <- input$Occur
    if (predtype == "BothTeamsAllow110+"){
    c(round(function2(input$aoff2, input$adef2,input$boff2,input$bdef2,input$ot2,input$combpace2),4),"%")

    }
  })

  else {
 return()
   }

}
)

0 个答案:

没有答案