6

これが私のサイトに埋め込まれた私のアプリです。アプリの下のスクロール ウィジェットを削除したいのですが、これは 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()))
})

どんな助けでも大歓迎です!

4

4 に答える 4

18

Shiny Homepageでアプリの html コードを調べてみました。また、tabsetPanel は、オプションをいずれか、などに<div>設定することで、html の (Document Division) タグを使用して調整されます。のサフィックスが大きいほど、分割の幅が大きくなります。そして、ui.R コードにタグを追加するだけです。classspan1span2span3spandiv()

div(
      tabsetPanel(
        tabPanel("Plot", 
                 plotOutput(
                   outputId = "histogram", 
                   height = "400px",
                   width = "400px")),
        tabPanel("Summary",
                 verbatimTextOutput(outputId = "datsummary"))
        ), class = "span7")
于 2013-10-01T03:32:20.117 に答える
12

幅 (および高さ) を調整する別の方法:

追加

 ),  style='width: 1000px; height: 1000px' # end of tabsetPanel

tabsetPanel の後、この場合 div() は必要ありません

于 2015-07-07T08:46:35.683 に答える
2

sidebarPanelとの幅を調整する別の方法は、とCSS クラスのプロパティをそれぞれtabsetPanel変更することに基づいていました。 を使用して、CSS を Shiny UI に直接追加することができます。 詳細については、 https://shiny.rstudio.com/articles/css.htmlを参照してください。 これは洗練されたソリューションではありませんが、正しく機能します。widthcol-sm-4col-sm-8
tag$headtag$style

光沢のある UI

shinyUI(fluidPage(
  tags$head(
    tags$style(HTML("   
     .col-sm-4 { width: 25%;}
     .col-sm-8 { width: 75%;}
    "))
  ),       
  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"))
    ))
)
)
于 2017-01-02T15:08:29.020 に答える