下标超出范围r闪亮r降价

时间:2019-07-19 17:01:09

标签: r shiny r-markdown

基本上,我正在以r markdown格式进行r闪亮。我收到一个错误:当我在r markdown中运行闪亮的应用程序时,下标超出范围。应用程序成功运行,但是在我关闭r markdown报告中的应用程序后,错误弹出。有什么办法解决这个问题?

  

下标超出范围

这是我在r markdown中的代码

```{r}
shinyApp(
ui <-fluidPage(
  theme=shinytheme("superhero"),
  titlePanel("Average Resale Price for current Model A and improvd houses and 5 has decline sharply by 30% when remaining lease years for current model A houses starts to reach at 92 "),
  sidebarLayout(
    sidebarPanel(
      selectInput("room","Rooms",choices=c("All","3 ROOM","4 ROOM","5 ROOM"),selected = "All"),
      selectInput('town','Town',choices = c("All",unique(df$town)),selected = "All")
    ),
    mainPanel(
      tabsetPanel(
        tabPanel("Summary", plotlyOutput(outputId = "lineChart")),
        tabPanel("Breakdown", plotlyOutput(outputId = "lineChart1")), 
        type="tab"

      )

    )
  )
),



# Define server logic required to draw a line graph ----

server <- function(input, output, session){
  df1<-reactive({
    if(input$room =="All" & input$town =="All"){
      df%>%
        dplyr::filter(flat_type %in% c("3 ROOM","4 ROOM","5 ROOM") , town %in% unique(df$town) )
    }
    else  if (input$room !="All"  &  input$town=="All"){
      df%>%
        dplyr::filter(flat_type %in% input$room, town %in% unique(df$town))
    }
    else  if (input$room =="All"  &  input$town!="All"){
      df%>%
        dplyr::filter(flat_type  %in% c("3 ROOM","4 ROOM","5 ROOM"), town %in% input$town)
    }

    else{
      df%>%
        dplyr::filter(flat_type %in% input$room,town %in% input$town)
    }
  })

  options(scipen = 100000)
  output$lineChart <- renderPlotly({
    ggplot(data = df1(),aes(x=remaining_lease,y=resale_price))+
      geom_smooth()+ 
      xlab("Remaining lease years") + 
      ylab("Average resale price")+
      ggtitle("Average resale price for current Model A and Improved houses against Remaining Lease Years")
  })

  output$lineChart1 <- renderPlotly({
    ggplot(data = df1(),aes(x=flat_type,y=resale_price))+
      geom_bar(stat = "identity")+
      xlab("Room Type") + 
      ylab("Average resale price")+
      ggtitle("Average resale price for current Model A and Improved houses against Remaining Lease Years")



  })

}
)
```

这是我的数据示例

    flat_model flat_type remaining_lease resale_price
1    MODEL A    5 ROOM              70       200000
2    MODEL A    3 ROOM              70        64300
3    MODEL A    3 ROOM              70        60000
4    MODEL A    3 ROOM              70        59000
5    MODEL A    4 ROOM              70        78000
6    MODEL A    4 ROOM              70       104000

这是错误的回溯

> subscript out of bounds
> 14. execCallbacks(timeoutSecs, all)
> 13. run_now(timeoutMs/1000, all = FALSE)
> 12. service(timeout)
> 11. serviceApp()
> 10. ..stacktracefloor..(serviceApp())
> 9. withCallingHandlers(expr, error = doCaptureStack)
> 8. globals$domain$wrapSync(expr)
> 7. promises::with_promise_domain(createStackTracePromiseDomain(), expr)
> 6. captureStackTraces({ while (!.globals$stopped) { ..stacktracefloor..(serviceApp()) Sys.sleep(0.001) ...
> 5. ..stacktraceoff..(captureStackTraces({ while (!.globals$stopped) { ..stacktracefloor..(serviceApp()) Sys.sleep(0.001) ...
> 4. runApp(x)
> 3. do.call("runApp", args)
> 2. print.shiny.appobj(x)
> 1. function (x, ...) UseMethod("print")(x)

0 个答案:

没有答案