r - 如何减小 R Shiny Web 应用程序中侧边栏面板的宽度?

标签 r shiny

library(shiny)

ui <- fluidPage(

    titlePanel("Hello"),
    sidebarLayout(
        sidebarPanel("Hello SideBar"),
        mainPanel("Hello MainPanel")
    )
)

server <- function(input, output) {

    
}

shinyApp(ui = ui, server = server)

仅通过目视,我现在就知道我的侧边栏面板大约占据了屏幕宽度的 33%。知道如何减少侧边栏的宽度以使主面板更大吗?

最佳答案

sidebarPanel 有一个宽度参数

width: The width of the sidebar. For fluid layouts this is out of 12 total units; for fixed layouts it is out of whatever the width of the sidebar's parent column is.

默认宽度为 4,这证实了您的目测估计 4/12 是三分之一。因此,要使其成为当前宽度的 1/2,您可以这样做:

ui <- fluidPage(

    titlePanel("Hello"),
    sidebarLayout(
        sidebarPanel("Hello SideBar", width=2),
        mainPanel("Hello MainPanel")
    )
)

关于r - 如何减小 R Shiny Web 应用程序中侧边栏面板的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54963915/

相关文章:

r - 在 sparklyr 中导入多个文件

R 在组内跨行连接但保留序列

python - 如何在 R 中重新获取 Python 变量?

r - 用公式引用 hell

r - 在 R 中按键查询 data.table

javascript - R shiny renderTable 改变单元格颜色

r - 使用 Leaflet/Shiny 选择和取消选择多个多边形时更改样式

r - 使用传单部署 R shiny 应用程序

r - 在 Shiny 中下载 RenderTable() 数据帧上的处理程序

r - 如何防止R在将长公式强制转换为字符时插入换行符?