闪亮的观察()

时间:2017-07-05 15:09:05

标签: r shiny reactive

我在使用以下代码中的observe()函数概念化错误的位置时遇到了一些麻烦:

observe({
  if (is.null(input$speciesSelect) | is.null(input$regionSelect))
  {
    output$height_summary_label <- renderUI(tags$b("Please select at least one species and at least one region"))
  } else
  {
    output$height_summary_label <- renderText("Height of selected corals (cm):")
    output$max_diam_summary_label <- renderText("Maximum diameter of selected corals (cm):")
    output$perp_diam_summary_label <- renderText("Perpendicular diameter of selected corals (cm):")
    output$depth_label <- renderText("Depth of selected corals (m):")

    output$height <- renderPrint(summary(summary_data()$HEIGHT))
    output$max_diam <- renderPrint(summary(summary_data()$MAX_DIAMETER))
    output$perp_diam <- renderPrint(summary(summary_data()$PERP_DIAMETER))
    output$depth <- renderPrint(summary(summary_data()$DEPTH))
    output$percent_disease <- renderPrint(paste("Disease present in", round((100 * nrow(subset(summary_data(), DISEASE == "present" | DISEASE == "P" | DISEASE == "p"))) / nrow(summary_data()), digits = 2) ,"percent of selected corals"))
    output$percent_bleach <- renderPrint(paste("Bleaching present in", round((100 * nrow(subset(summary_data(), BLEACH_CONDITION == "PL" | BLEACH_CONDITION == "P" | BLEACH_CONDITION == "T"))) / nrow(summary_data()), digits = 2), " percent of selected corals"))
  } 
})

问题是,如果我点击立即显示带有统计数据的模态窗口的按钮,它会输出"Please select..."消息,这很好。但是如果我点击checkboxGroupInput中的某个区域和物种然后取消它们,然后打开模态,它会为每个输出显示"Error: argument is of length zero"

0 个答案:

没有答案
相关问题