r - R闪亮组多个textOutputs
问题描述
我想将一些 textOutput() 值整齐地组合在一个框中。我知道这可以使用 shinydashboard::box() 来完成,但这意味着更改我的应用程序布局中的所有内容,而我不想这样做。有没有办法在基础闪亮本身中做到这一点?
我想在我的 textOutputs 周围有一个简单的框,最好与侧边栏面板分开并在其下方。
可重现的例子:
library(ggplot2)
library(shiny)
ui <- fluidPage(
sidebarPanel(
selectInput("var", choices = c("mpg", "disp"), label = "Selected Input"),
textOutput("foo1"),
textOutput("foo2"),
textOutput("foo3"),
textOutput("foo4")
),
mainPanel(
plotOutput("plot1", hover = "plot_hover")
)
)
server <- function(input, output) {
output$plot1 <- renderPlot({
ggplot(mtcars, aes_string(x = 'wt', y=input$var)) + geom_point()
})
output$foo1 <- renderText("This is text output 1")
output$foo2 <- renderText("This is text output 2")
output$foo3 <- renderText("This is text output 3")
output$foo4 <- renderText("This is text output 4")
}
shinyApp(ui, server)
和应用程序:
我想要的是:
一个单独的框,将我的 textOutputs 分组在一个位置,在 sidbarPanel 区域的外部和下方
解决方案
<div>
您可以通过添加标签并为其添加边框来绘制简单的“框” 。例如
ui <- fluidPage(
sidebarPanel(
selectInput("var", choices = c("mpg", "disp"), label = "Selected Input"),
div(style="border:1px solid red",
textOutput("foo1"),
textOutput("foo2"),
textOutput("foo3"),
textOutput("foo4")
)
),
mainPanel(
plotOutput("plot1", hover = "plot_hover")
)
)
或者您可以添加一个类属性。您只需要使用 CSS 自己进行样式设置。
推荐阅读
- algorithm - 从每对的总和中找到第 k 个总和
- ruby-on-rails - 说`Post`是一个模型,一个继承自`ApplicationRecord`的类,在rails中。那么,Post.arel_table.create_table_alias 做了什么?
- vba - 对于每个 Ws 循环不切换工作表
- python - 从不同目录导入二进制包
- python - Python:给定三个其他矩阵的语句,将 NaN 分配给矩阵元素
- powershell - 用于列表的 Powershell 命令 SetUser
- join - 在pyspark中水平连接多个数据框
- sql-server - 查询中的慢排序
- vba - vba 在一个单元格中合并几行
- jquery - 隐藏和禁用展开图标