problem with nested shiny apps

177 views
Skip to first unread message

Inzirio

unread,
Nov 25, 2015, 10:43:49 AM11/25/15
to Shiny - Web Framework for R
hello everyone,

I'm trying to build a big shiny application, made by several miniapplications. 

The idea was to build an application with a navbarPage (A) on the top, constituted by tabPanel(s) and navbarMenu(s), and for some of these voices the possibility to have a "lateral menu" (B) (sidebarPanel or similar) on the left with other voices.

Finally, for each of these voice, the possibility to have just an application structured with a left panel (C) positioned next to the "left menu" (B), and the outputmenu (D) on the right.

here i report a cropped screenshot to give a visual idea:














As you can see, the panel C and the outputmenu D are positioned in a separated "scrollable" frame. This problem is visible invoking the shinyApp function when the "1" voice is selected from the "left panel" B.

Here I report a simplified code divided in files:

##### Main app code:
MainUI <- fluidPage(
  navbarPage(title = "title",
                      ## other voices
                      navbarMenu("voice 5",
                                 tabPanel("menu 1",
                                          uiOutput("menu51")
                                 ),
                                 tabPanel("...")
                      )
  )
)

MainServer <- function(input, output, session) {
  output$menu51 <- renderUI({
    menu51UI
  })
  
}

##### menu51 code:
menu51UI <- fluidPage(
    navlistPanel(
      "menu 5>1",
      tabPanel("1",
               shinyApp(exampleUI, exampleServer)
               ),
      tabPanel("2"),
      tabPanel("3"),
      widths=c(2,10)
    )
)

BedUtilitiesServer <- function(input, output, session) {
##
}

##### example app code:
exampleUI <- fluidPage(
  titlePanel("Sort"),
  fluidRow(
    column(2, 
      wellPanel(
        checkboxInput(inputId = 'directory_flag', label = 'Directory path?', value = FALSE),
        fileInput(inputId = "infiles", label = "Choose file(s)", multiple = TRUE),
        checkboxInput(inputId = 'descending_flag', label = 'Descending', value = FALSE),
        checkboxInput(inputId = 'merge_flag', label = 'Merge', value = FALSE),
        actionButton(inputId = "sortbed_button", label="sort file(s)", width = "100%", icon = icon(name="sort")),
        tags$hr(),
        tags$p("Loaded file(s):"),
        verbatimTextOutput("file_loaded")
      )
    ),
    column(8,
           uiOutput("data_tables")
    )
  )
)

exampleServer <- function(input, output, session) {
 ## some computation functions
}



In order to avoid this problem, I decided to replace the call to shinyApp(exampleUI, exampleServer) with an uiOutput("example_ui").
The code becames:
##### Main app code:
MainUI <- fluidPage(
  navbarPage(title = "title",
                      ## other voices
                      navbarMenu("voice 5",
                                 tabPanel("menu 1",
                                          uiOutput("menu51")
                                 ),
                                 tabPanel("...")
                      )
  )
)

MainServer <- function(input, output, session) {
  output$menu51 <- renderUI({
    menu51UI
  })
  
}

##### menu51 code:
menu51UI <- fluidPage(
    navlistPanel(
      "menu 5>1",
      tabPanel("1",
               ########
               uiOutput("example_ui")
               ),
      tabPanel("2"),
      tabPanel("3"),
      widths=c(2,10)
    )
)

BedUtilitiesServer <- function(input, output, session) {
output$example_ui <- renderUI({
    #######
    exampleUI 
  })
}

##### example app code:
exampleUI <- fluidPage(
  titlePanel("Sort"),
  fluidRow(
    column(2, 
      wellPanel(
        checkboxInput(inputId = 'directory_flag', label = 'Directory path?', value = FALSE),
        fileInput(inputId = "infiles", label = "Choose file(s)", multiple = TRUE),
        checkboxInput(inputId = 'descending_flag', label = 'Descending', value = FALSE),
        checkboxInput(inputId = 'merge_flag', label = 'Merge', value = FALSE),
        actionButton(inputId = "sortbed_button", label="sort file(s)", width = "100%", icon = icon(name="sort")),
        tags$hr(),
        tags$p("Loaded file(s):"),
        verbatimTextOutput("file_loaded")
      )
    ),
    column(8,
           uiOutput("data_tables")
    )
  )
)

exampleServer <- function(input, output, session) {
 ## some computation functions
}

All works, except for the exampleUI that never appears!!!!

How is that possible? Can someone helps me? Any ideas? Any errors?

Thanks,
inzirio


Reply all
Reply to author
Forward
0 new messages