I am using these commands for the ui.R in Shiny. Now each of these methods run individually but when I try running 2 methods from the same group, say group1 methods. It does not show me outputs.
please look into the sample code or ui and server and suggest changes.
I am trying to display heatmaps and tables for this kind of data. As shown the server code repeats for method "M". In that case the methods S doesnt show any plots or tables. Sometimes occasionally, it prints out the table but not the plot. They are named similarly with some changes to the variable names.
In short, I am able to show the outputs when a method is selected (M or S). I want it to show the outputs when both the methods are selected (M and S)
# packages used
library(shiny)
library(shinyWidgets)
library(shinyjs)
library(MASS)
library(preprocessCore)
library(DT)
library(pheatmap)
library(ggplot2)
#---------ui-----------------
ui <- fluidPage(
navbarPage("2 groups of methods"),
tabsetPanel(id = "tabs",
tabPanel(id = "tab1", title = "Submit info",
hr(),
fluidRow(
column(10,
wellPanel(
awesomeCheckboxGroup("method",
label = ("group1 methods"),
choices = c("M1" = "M", "S1"='S'),
inline = TRUE, status = "primary"
),
# if method = M or S then execute below.
conditionalPanel(
condition = "input.method.includes('M') || input.method.includes('S')",
wellPanel(
awesomeCheckboxGroup(inputId = "internal_data", "Choose our data",
c("one"="one", "two"="two")),
)
)
)
)
)
)
),
tabPanel(title = "plots",
fluidRow(column(width = 4,
wellPanel(
plotOutput("plot"),
DT::dataTableOutput("table"),
)
)
)
)
)
#---------SERVER-----------------
server <- function(input, output, session){
plot_method = reactiveVal()
output_methods <- reactive({
if(input$internal_data == "one" && input$method == "M"){
log_info("Deconvolution with MUSIC started")
isolate({
x <- data.frame(replicate(10,sample(0:1,100,rep=TRUE)))
plot_method(pheatmap(x))
})
}
if(input$internal_data == "two" && input$method == "M"){
log_info("Deconvolution with MUSIC started")
isolate({
x <- data.frame(replicate(10,sample(100:101,300,rep=TRUE)))
plot_method(pheatmap(x))
})
}
x <- x
})
output$table <- DT::renderDataTable({
output_methods()
})
output$plot <- renderPlot({
plot_method()
})
}