【问题标题】:Change download button position in a tab panel in shiny app在闪亮的应用程序中更改选项卡面板中的下载按钮位置
【发布时间】: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)

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    试试这个

    tabPanel("Table",
             fluidRow(column(10,tableOutput("table")),
                      column(3, style = "margin-top: 500px;",
                             downloadButton("download", "Download",
                             style="color: #fff; background-color: green; border-color: Black;"))
             )),
    

    您应该将边距更改为表格输出的高度。我给了500px。

    【讨论】:

      猜你喜欢
      • 2018-07-24
      • 2016-03-22
      • 1970-01-01
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-30
      • 2014-01-21
      相关资源
      最近更新 更多