r - 在shinydashboard中加载RData文件时出现条件面板
问题描述
我正在制作一个闪亮的应用程序,它与我存储为RData
文件的大 data.frame 交互。我希望用户选择文件,一旦 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)
我已经使用Make conditionalPanel 中提供的解决方案依赖于使用 fileInput 上传的文件,但我无法使其工作,还有另一个使用shinyjs
包的实现,但不知道如何在我的示例中使用它
解决方案
推荐阅读
- xml - 有没有一种简单的方法可以通过 bash 命令验证 xsd 中的 schematron
- javascript - Tabulator.js 的 id 可访问性不起作用
- html - 无法在 Firefox 中测量 Html-Image 的 Clientwidth
- python - NLP:为什么在 sklearn 管道中使用两个向量器(词袋/TFIDF)?
- c++ - 哪个 DLL 有 PathCchAppend?
- javascript - 设置间隔仅在第一次工作。有什么解决办法吗?
- javascript - Html.BeginForm 处理多个按钮和 Javascript 验证
- scala - Scala / Neo4J - 删除/删除节点之间的关系路径并返回 true 或 false 作为结果
- c++ - 如何使用所有额外文件信息(如 Haar Cascade 训练权重的 XML 文件)编译代码?
- php - wp_nonce_field 字段是否使用与 google reCaptcha 相同的保护?