make conditionalPanel появляется при загрузке файла RData в Shinydashboard - PullRequest
0 голосов
/ 28 декабря 2018

Я делаю блестящее приложение, которое взаимодействует с большим data.frame, который я сохранил как файл RData.Я хочу, чтобы пользователь выбрал файл, и как только RData будет полностью загружен (это займет ~ 15 секунд), должна появиться вторая панель, позволяющая пользователю ввести имя образца и выполнить некоторые операции.

Вот какмое приложение выглядит сейчас

header <- dashboardHeader(title="Analysis and database")

sidebar <- dashboardSidebar(
   useShinyjs(),
   sidebarUserPanel(),
   hr(),
sidebarMenu(
# Setting id makes input$tabs give the tabName of currently-selected tab
id = "sidebarmenu",
menuItem("Analyse old data by Sample", tabName="oldfile", icon = icon("table"), startExpanded = FALSE),
fileInput(inputId = "file1", "Choose database file"),
    conditionalPanel(
    #condition = "input.sidebarmenu === 'oldfile'",
    condition = "output.fileUploaded == 'true' ",
    textInput(inputId = "sample", label ="Type a sample ID"),
    actionButton("go2", "Filter")
  )
 )
)

body <- dashboardBody(
 tags$style(type="text/css",
  ".shiny-output-error { visibility: hidden; }",
  ".shiny-output-error:before { visibility: hidden; }"),
tabItems(
  tabItem("oldfile", "Sample name data.table",
        fluidRow(DT::dataTableOutput('tabla_oldfile') %>% withSpinner(color="#0dc5c1")))
 )
)

  ui <- dashboardPage(header, sidebar, body)

### SERVER SIDE

server = function(input, output, session) {
  options(shiny.maxRequestSize=100000*1024^2)

prop <- reactive({

 if (input$go2 <= 0){
     return(NULL)
 }
 result <- isolate({
        if (is.null(input$file1))
            return(NULL)
        if (is.null(input$sample))
            return(NULL)
        inFile <- input$file1
        print(inFile$datapath)
        #big_df <- load(inFile$datapath)
        print (big_df)
        print(input$sample)
        oldtable <- big_df1 %>% filter_at(vars(GATK_Illumina.samples:TVC_Ion.samples), 
            any_vars(stringi::stri_detect_fixed(., as.character(input$sample))))
        oldtable
     })
 result
 })

output$fileUploaded <- reactive({
return(!is.null(prop()))
})
outputOptions(output, 'fileUploaded', suspendWhenHidden=FALSE)

output$tabla_oldfile <- DT::renderDataTable({

DT::datatable(prop(), 
              filter = 'top', 
              extensions = 'Buttons',
              options = list(
                dom = 'Blftip',
                buttons = 
                  list('colvis', list(
                    extend = 'collection',
                    buttons = list(list(extend='csv',
                                        filename = 'results'),
                                   list(extend='excel',
                                        filename = 'results'),
                                   list(extend='pdf',
                                        filename= 'results')),
                    text = 'Download'
                  )),
                scrollX = TRUE,
                pageLength = 5,
                lengthMenu = list(c(5, 15, -1), list('5', '15', 'All'))
              ), rownames = FALSE
    )
  })

 }
shinyApp(ui, server)

Я использовал решение, предоставленное в Сделать так, чтобы conditionalPanel зависел от файлов, загруженных с fileInput , но я не могу заставить его работать, есть другая реализация, использующая shinyjs пакет, но не знаю, как использовать его на моем примере

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...