r - Shiny:如何调整tabsetPanel的宽度?

标签 r shiny

这是我的 app嵌入我的网站。我想摆脱应用程序下方的滚动小部件,这是由于 tabsetPanel 的宽度造成的。

我使用以下代码嵌入应用程序:

<iframe width="800" height="480" frameborder="0" src="http://spark.rstudio.com/alstated/meanvar/"></iframe>

应用程序代码:

ui.R

library(shiny)

# Define UI for application that plots random distributions 
shinyUI(pageWithSidebar(
  headerPanel(title = ""),
  sidebarPanel(
    sliderInput("size",
                "Number of Observations",
                min = 10,
                max = 200,
                value = 95),

    sliderInput("mu",
                "Mean",
                min = -100, 
                max = 100,
                value = 0),

    sliderInput("sd",
                "Standard Deviation",
                min = 1,
                max = 6,
                value = 3),

    checkboxInput(inputId = "indiv_obs",
                  label = "Show individual observations",
                  value = FALSE),

    checkboxInput(inputId = "density",
                  label = "Show density estimate",
                  value = FALSE),

    conditionalPanel(condition = "input.density == true",
                     sliderInput(inputId = "bw_adjust",
                                 label = "Bandwidth Adjustment",
                                 min = 0.2,
                                 max = 2,
                                 value = 1,
                                 step = 0.2))
  ),
  mainPanel(
    tabsetPanel(
      tabPanel("Plot", 
               plotOutput(
                 outputId = "histogram", 
                 height = "400px",
                 width = "400px")),
      tabPanel("Summary",
               verbatimTextOutput(outputId = "datsummary"))
    ))
)
)

服务器.R

library(shiny)

# Define server logic required to generate and plot a random distribution
shinyServer(function(input, output) {

  data <- reactive(rnorm(
    n = input$size, 
    mean = input$mu, 
    sd = input$sd
  ))

  output$histogram <- renderPlot({

    hist(data(),
         probability = TRUE,
         xlab = "Data",
         ylab = "Density",
         main = "Histogram of Random Samples")

    if(input$indiv_obs){
      rug(data())
    }

    if(input$density){
      dens <- density(data(), adjust = input$bw_adjust)
      lines(dens, col = "blue")
    }

  })

  output$datsummary <- renderPrint(summary(data()))
})

非常感谢任何帮助!

最佳答案

我现在明白了,我检查了 Shiny 上应用程序的 html 代码 Homepage 。并且使用 <div> 调整 tabsetPanel通过设置选项 class 在 html 中(文档划分)标记到 span1 , span2 , span3等等。 span的后缀越高划分的宽度越大。我只是添加 div()我的 ui.R 代码中的标记:

div(
      tabsetPanel(
        tabPanel("Plot", 
                 plotOutput(
                   outputId = "histogram", 
                   height = "400px",
                   width = "400px")),
        tabPanel("Summary",
                 verbatimTextOutput(outputId = "datsummary"))
        ), class = "span7")

关于r - Shiny:如何调整tabsetPanel的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19096439/

相关文章:

r - 将 R 中选定的列转置为行

r - 无法访问用于生成动态 Shiny 内容的函数内部的 react 对象

R Shiny 和 Spark : how to free Spark resources?

R Shiny : custom icons doesn't render

r - 具有用户身份验证的 Shiny 仪表板

R:按名称组合嵌套列表元素

r - 在 R 中将列表列的部分设置为 NULL

r - 如何让 spplot (lattice) 不在多边形周围绘制边框

json - R data.frame 到带有子节点/分层结构的 JSON

r - 来自 Shiny 应用程序的写入权限