Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

RenderUI for both table and plot?

$
0
0

I have somehow tried to make an application to extract all stocks data. The below code is working. But, at the last, there are radio buttons like shown below. So when I click the radiobuttons (All, Open, Close, High and Low), the ggplot should appear for a particular company. I have also written the code also.

For example. When I click "All", the ggplot for Open, High, Close and Low should appear. But when I select Open, the plot should be only for Open. Hope I am making sense. The code is almost fine, But when I click the radio buttons, the plot is not getting displayed.

enter image description here

---
output$t10 <- renderPlot({
    if (!is.null(input$C) && !is.null(input$S)){
       asd1 <- input$C
       days <- input$S
       as2 <- tq_get(asd1, from = Sys.Date()-days, to = Sys.Date())
       as2 <- as.data.frame(as2)
       as21 <- as2[c(1:5)]
       as2_melt <- melt(as2,id=c("date"))
       plot_data <- as2_melt
    } 
    if (!is.null(input$C) && !is.null(input$S) && input$R12 == "All")
    {
      plot_data <- plot_data
    }
    if (!is.null(input$C) && !is.null(input$S) && input$R12 != "All")
    {
      plot_data <- plot_data %>% filter(variable %in% input$R12)
    }
    if (!is.null(input$C) && !is.null(input$S) && input$R12 == "All")
    {
      ggplot(data = plot_data,aes(x=date,y=value,fill=variable))+geom_line(size=0.2)
    }
    if (!is.null(input$C) && !is.null(input$S) && input$R12 != "All")
    {
      ggplot(data = plot_data,aes(x=date,y=value,fill=variable))+geom_line(size=0.2)
    }
})

output$filter_70 <- renderUI(
  if (input$R == "Individual Company") {
  dataTableOutput("table1")
} else if (input$R == "Multiple Companies") {
  dataTableOutput("table12")
} else if (!is.null(input$C) && !is.null(input$S) && input$R12 == "All"){
  plotOutput("t10")
}
)
uiOutput("filter_70")
```

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>