【发布时间】:2023-03-20 17:55:01
【问题描述】:
我正在开发一个闪亮的应用程序,并使用带有标签面板的mainPanel()。第一个tabPanel() 应该包含一个tableOutput() 和一个downloadButton()。 downloadButton() 的对齐方式如下图所示。
只有在生成输出表时它才会关闭。我希望它从一开始就与表格底部对齐。我应该对我的代码进行哪些更改?
代码如下:
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectizeInput(inputId = "gender1",
label = "Choose samples to compare",
choices = genders,
options = list(
placeholder = 'Sample 1',
onInitialize = I('function() { this.setValue(""); }'))),
conditionalPanel("input.gender1 != ''",
selectizeInput(inputId = "gender2",
label = NULL,
choices = '',
options = list(
placeholder = 'Sample 2',
onInitialize = I('function() { this.setValue(""); }')))),
actionButton(inputId = "button", label = "Plot",
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"))),
mainPanel(
tabsetPanel(
tabPanel("Table", tableOutput("table"),
downloadButton("download", "Download",
style="color: #fff; background-color: green; border-color: Black;")),
tabPanel("Volcano Plot", plotOutput("vplot",width = "550px", height="350px")),
tabPanel("PCA Plot", plotOutput("pcaplot",width = "550px", height="350px")),
tabPanel("Heatmap",plotOutput("hplot",width = "550px", height="350px")),
tabPanel("Manhattan plot", plotOutput("mplot"))
)
)))
server <- function(input, output,session) {
observe({
input$gender1
updateSelectizeInput(session, 'gender2',choices = genders[genders != input$gender1],options = list(
placeholder = 'Sample 2',
onInitialize = I('function() { this.setValue(""); }')))
})
observeEvent(input$button,{output$table <- renderTable({isolate(fitData(input$gender1,input$gender2))})
output$download <- downloadHandler(
filename = function(){paste(input$gender1,inputSamples,".csv",sep = ' with ')},
content = function(file){
write.csv(fittable(),file)})
shinyApp(ui = ui, server = server)
【问题讨论】: