RenderUI for both table and plot?

Hi all,

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.

image

---
title: "Stock Analysis"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: scroll
    theme: united
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyquant)
library(dplyr)
library(ggplot2)
```

```{r}
Ticker <- data.frame(Ticker = c("1STCUS.BO","21STCENMGM.BO"))
Ticker <- as.data.frame(Ticker)
```

Company Daily Stocks
=================

Inputs {.sidebar}
-----------------------------------------------------------------------
```{r}
    radioButtons("R","Parameters",choices = c("Individual Company","Multiple Companies"),selected = character(0),inline = F)
    output$filter1 <- renderUI({
      if(input$R == "Individual Company"){
        label = "Company"
        selectInput("C",label,choices = c("",levels(factor(Ticker$Ticker))))
      } else if(input$R == "Multiple Companies"){
        label = "Companies"
        selectInput("C1",label,choices = c("",levels(factor(Ticker$Ticker))),multiple = TRUE)
      }
    })
    uiOutput("filter1")
    
    actionButton("A","Execute",icon = NULL)
    
    output$filter2 <- renderUI({
      if(input$R == "Individual Company"){
        label = "Since No of days"
        sliderInput("S",label,min = 1,max = 100,value = 10)
      } else if(input$R == "Multiple Companies"){
        label = "Since No of days"
        sliderInput("S1",label,min = 1,max = 10,value = 10)
      }
    })
    uiOutput("filter2")
    
    
    output$filter3 <- renderUI({
      if(input$R == "Individual Company"){
        label = "Open-Close-High-Low"
        radioButtons("R12",label,choices = c("All","Open","Close","High","Low"),selected = character(0),inline = F)
      } else if(input$R == "Multiple Companies"){
        label = "Segments"
        radioButtons("R12",label,choices = c("Open","Close","High"),selected = character(0),inline = T)
      }
    })
    
    uiOutput("filter3")
```

Column {data-height=7000}
-----------------------------------------------------------------------

### Stocks Table

```{r}
observeEvent(input$A,{
  if(!is.null(input$C) && !is.null(input$S)) {
    #asd <- data.frame(a=c(input$C[]))
    asd1 <- input$C
    days <- input$S
    as2 <- tq_get(asd1, from = Sys.Date()-days, to = Sys.Date())
    as2 <- as.data.frame(as2)
    
    output$table1 <- renderDataTable({
    print(as2[rev(order(as2$date)),])
    })
  }
   else {
    output$table1 <- renderDataTable({
    })
  }
})

observeEvent(input$A,{
  if(!is.null(input$C1) && !is.null(input$S1)) {
    #asd <- data.frame(a=c(input$C[]))
    asd1 <- input$C1
    days <- input$S1
    as23 <- tq_get(asd1, from = Sys.Date()-days, to = Sys.Date())
    as23 <- as.data.frame(as23)
    as23$`H-L` <- as23$high-as23$low
    asa <- as23 %>% group_by(symbol) %>% summarise('mean `H-L`'=mean(`H-L`),'sd `H-L`'=sd(`H-L`))
    
    output$table12 <- renderDataTable({
    print(asa)
    })
  }
   else {
    output$table12 <- renderDataTable({
    })
  }
})

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")
```