我有一个如下所示的shinydashboard:

# Packages
library(shinydashboard)
library(tidyverse)
library(readxl)
library(scales)
theme_set(theme_light())
header <- dashboardHeader(
title = "Test App",
titleWidth = 215
)
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Test Tab", tabName = "test_tab",
icon = icon("paper-plane"), startExpanded = TRUE)
)
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "test_tab",
fluidRow(
column(width = 4,
h2("Column X"),
valueBoxOutput("first_value", width = NULL),
box(flexdashboard::gaugeOutput("second_value", width = "90%", height = "100px"),
title = "Second Value", status = "primary", solidHeader = TRUE,
collapsible = FALSE, width = NULL
)
),
column(width = 8,
h2("Column Y"),
box(
title = "#3", status = "primary", solidHeader = TRUE,
collapsible = FALSE, width = 4
),
box(
title = "#4", status = "primary", solidHeader = TRUE,
collapsible = FALSE, width = 4
)
)
),
fluidRow(
h2("Row A"),
column(width = 12,
box(title = "Third Value", status = "primary", solidHeader = TRUE,
width = 2.4),
box("Fourth Value", status = "primary", solidHeader = TRUE,
width = 2.4),
box("Fifth Value", status = "primary", solidHeader = TRUE,
width = 2.4),
box("Sixth Value", status = "primary", solidHeader = TRUE,
width = 2.4),
box("Seventh Value", status = "primary", solidHeader = TRUE,
width = 2.4)
)
)
)
)
)
# Put them together into a dashboardPage
ui <- dashboardPage(skin = "blue", header = header,
sidebar = sidebar,
body = body)
server <- function(input, output) {
output$first_value <- renderValueBox({
valueBox(
comma_format()(100000),
subtitle = "First Value",
icon = icon("list"), color = "purple"
)
})
output$second_value = flexdashboard::renderGauge({
flexdashboard::gauge(0.12 * 100,
symbol = '%',
min = 0,
max = 100)
})
}
shinyApp(ui, server)我正在尝试让RowA下面的框()以五列的格式排列,如下所示:
Third Value | Fourth Value | Fifth Value | Sixth Value
我不确定在这里我该怎么做。我试着在fluidRow()中的column()中放置了5个框,但不幸的是,框总是水平显示……
有没有办法以列的形式显示这些框?如果没有,你能指导我使用与我的功能相似的其他功能吗?
发布于 2019-05-22 17:56:04
您已经将这五个框中每个框的列宽指定为2.4 (我猜是12/5)。
列宽应为整数。如果你用2.4代替2,它就会工作得很好。
请注意,您将在框5的右侧有一个空列,对应于剩余的2 (12 - 2*5)个位置。
这是基于引导列布局的。有关详细信息,请参阅this教程。
https://stackoverflow.com/questions/56249127
复制相似问题