R Shiny情节不会渲染

时间:2017-06-26 12:36:12

标签: r plot shiny

嗨,任何人都可以看到下面的代码有什么问题吗?

 output$zscore_chart <- renderPlot({

   xvals <- 2:186 
   req(input$countrySelectZScore)
   idx_country = which(input$countrySelectZScore == esiCountries)



   max_comp_z <- max(esiData_DF[idx_country, 2:186], na.rm = TRUE)

   overall_max_z <- max(max_comp_z, na.rm = TRUE)

   foo = ts(esiData_DF[idx_country, 2:186], frequency = 12, start = 2001)
   dates = seq(as.Date("2001-01-01"), by = "month", along = foo)

   plot(x = 2:186, y = esiData_DF[idx_country, 2:186], type = "l", 
        xlab = "", ylab = "", col = "grey20", ylim = c(-2, overall_max_z),
        lwd=3,las=2)
    mtext("Quarterly percentage changes", side = 3, adj = 0, line = 0.1, 
      cex = 1, font = 0.5)
    axis(1, at = xvals, label = dates, cex.axis = 1, las = 2)
    mtext("Economic Sentiment Indicators", side = 3, adj = 0, 
          line = 1.2, cex = 2, font = 2)

    legend(
      "bottom", 
      lty = c(1,1), 
      lwd = c(3,3), 
      col = c("grey20", "green2"), 
      legend = c("Economic Sentiment Indicator", "GDP growth"),
      bty = "n",
      xjust = 0.5,
      yjust = 0.5,
      horiz = TRUE
    )
  }, height = 525)

esiData_DF是用于索引和绘制正确数据的DF。数据框的左侧是国家/地区名称,日期是每月一次。我需要渲染图,但它不会在我运行应用程序时。有什么想法吗?

enter image description here

数据继续向右,截至2017年5月每月。

0 个答案:

没有答案