在 Shiny 中的 Bs4card 中创建一个列

Create a column within a Bs4card in Shiny

我有一个 bs4card,我想并排添加 2 个选择输入。正如您从所附照片中看到的那样,即使列宽设置为 6,选择输入也会被压缩。

下面是我的代码...

bs4Card(
      width =6,
      title = "Position Re-Balancer",
      collapsible = F,
      closable = F,
      maximizable = T,
      elevation = 2,
 
  #block of code which we are looking at
  fluidRow(
  column(width = 6,
  selectizeInput("bullpos", "Bull", choices = l.etfs$Bull)
  ),
  column(width = 6,
  numericInput("positionbull", "Bull Shares", value = -100)
  )
  ),
  
  selectizeInput("bearpos", "Bear", choices = l.etfs$Bear),
  numericInput("positionbear", "Bear Shares", value = -100),
  numericInput("moneyallocated", "Max $ Allocation", value = 5000)
  
  
) 

这里是 bs4Card 帮助页面的改编示例。我用了你的卡,但是把卡的 width 设置为 12.

library(shiny)
library(bs4Dash)

shiny::shinyApp(
  ui = bs4DashPage(
    navbar = bs4DashNavbar(),
    sidebar = bs4DashSidebar(),
    controlbar = bs4DashControlbar(),
    footer = bs4DashFooter(),
    title = "test",
    body = bs4DashBody(
      fluidRow(
        column(
          width = 6,
          bs4Card(
            title = "Closable Box with dropdown", 
            closable = TRUE, 
            width = 12,
            status = "warning", 
            solidHeader = FALSE, 
            collapsible = TRUE,
            cardLabel = bs4CardLabel(
              text = 1,
              status = "danger",
              tooltip = "Hello!"
            ),
            dropdownMenu = dropdownItemList(
              dropdownItem(url = "http://www.google.com", name = "Link to google"),
              dropdownItem(url = "#", name = "item 2"),
              dropdownDivider(),
              dropdownItem(url = "#", name = "item 3")
            ),
            p("Box Content")
          )
        ),
        column(
          width = 6, 
          bs4Card(
            width =12,
            title = "Position Re-Balancer",
            collapsible = F,
            closable = F,
            maximizable = T,
            elevation = 2,
            
            #block of code which we are looking at
            fluidRow(
              column(width = 6,
                     selectizeInput("bullpos", "Bull", choices = c("A", "B"))
              ),
              column(width = 6,
                     numericInput("positionbull", "Bull Shares", value = -100)
              )
            ),
            
            selectizeInput("bearpos", "Bear", choices = c("A", "B")),
            numericInput("positionbear", "Bear Shares", value = -100),
            numericInput("moneyallocated", "Max $ Allocation", value = 5000)
            
            
          ) 
        )
      )
    )
  ),
  server = function(input, output) {
    output$distPlot <- renderPlot({
      hist(rnorm(input$obs))
    })
  }
)

这里看起来不错。为了更好地理解代码中的问题所在,请提供一个最小的可重现示例,即 运行 应用程序和您使用的 UI。