R-shiny; single input to control 2 outputs

Hi All,
I have a noob question. I am trying to output 2 data sets in shiny. I want the input to be a single field.
A common variable that is present in both data sets is used as input. So would like a selection in input fild affect both the data set outputs.
only the selection "All" is working. if I select All, I see the complete records from both datasets. But if I start filtering a particular value a blank output is coming out. Here is the warning I see
"Warning: Unknown or uninitialised column: 'adae'.
Warning: Length of logical index must be 1 or 1906, not 0
Warning: Unknown or uninitialised column: 'subs_sev'.
Warning: Length of logical index must be 1 or 9, not 0
"Please see code below. Thank you in advance for helping.
###Code starts below

library(shiny)

Define UI for application that draws a histogram

ui <-
fluidPage(
titlePanel("Basic DataTable"),

# Create a new Row in the UI for selectInputs
fluidRow(
  column(4,
         selectInput("USUBJID",
                     "SUBJECT:",
                     c("All",
                       unique(as.character(adae$USUBJID))))
  )
  
),
# Create a new row for the table.
fluidRow(
  column(6, DT::dataTableOutput("table"))
),

# Create a new row for the table.
fluidRow(
  column(6, DT::dataTableOutput("table1"))
)

####end of fluidpage

)

server <- function(input, output) {

Filter data based on selections

output$table <- DT::renderDataTable(DT::datatable({
data <- adae
if (input$USUBJID != "All") {
data <- data[data$adae %in% input$USUBJID,]
}

data

}))

Filter data based on selections

output$table1 <- DT::renderDataTable(DT::datatable({
data1 <- subs_sev
if (input$USUBJID != "All") {
data1 <- data1[data1$subs_sev %in% input$USUBJID,]
}

data1

}))

}

Run the application

shinyApp(ui = ui, server = server)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.