Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny - Adjust width of sidebarPanel() relative to mainPanel()

Tags:

r

shiny

I have the following segment of code which works as part of my shiny UI:

fluidPage(
      titlePanel("Complaints this month"),
      tabsetPanel(
        tabPanel(
          "Opened",
          sidebarLayout(
            sidebarPanel(
              sliderInput('sampleSize', 'Sample Size', min = 1, max = nrow(ThisMonthCreated),
                          value = 1000, step = 500, round = 0),
              selectInput('Openedx', 'X', choices = nms1, selected = "ActualDateCreated"),
              selectInput('Openedy', 'Y', choices = nms1, selected = "TimeToAcknowledge"),
              selectInput('Openedcolor', 'Color', choices = nms1, selected = "SimpleBusinessArea"),

              selectInput('Openedfacet_row', 'Facet Row', c(None = '.', nms1), selected = "none"),
              selectInput('Openedfacet_col', 'Facet Column', c(None = '.', nms1)),
              sliderInput('OpenedHeight', 'Height of plot (in pixels)', 
                          min = 100, max = 2000, value = 680)
            ),
            mainPanel(
              plotlyOutput("Open", height = "600px")
            )
          )
        )
      )
    )
  )

I tried to adjust the sidebarpanel by messing with the width of the stuff within it but of course that doesn't affect the actual width of the sidebarpanel. It only affects the size of the specific things inside, so it doesn't provide the desired outcome:

sidebarLayout(
            sidebarPanel(
              sliderInput('sampleSize', 'Sample Size', min = 1, max = nrow(ThisMonthCreated),
                          value = 1000, step = 500, round = 0, width = "50%"),
              selectInput('Openedx', 'X', choices = nms1, selected = "ActualDateCreated", width = "50%"),
              selectInput('Openedy', 'Y', choices = nms1, selected = "TimeToAcknowledge", width = "50%"),
              selectInput('Openedcolor', 'Color', choices = nms1, selected = "SimpleBusinessArea", width = "50%"),

              selectInput('Openedfacet_row', 'Facet Row', c(None = '.', nms1), selected = "none", width = "50%"),
              selectInput('Openedfacet_col', 'Facet Column', c(None = '.', nms1), width = "50%"),
              sliderInput('OpenedHeight', 'Height of plot (in pixels)', 
                          min = 100, max = 2000, value = 680, width = "50%")
            ),
            mainPanel(
              plotlyOutput("Open", height = "600px")
            )
          )

I want it so that the sidebar panel is 1/3 (I may wan't to adjust this depending on how it looks) of the main panel. Would this be doable or would I have to provide specific width arguments (e.g 1000px) for both panels in each tab I make?

Thanks in advance

like image 541
Saleem Khan Avatar asked Dec 15 '17 15:12

Saleem Khan


1 Answers

Simple sidebarPanel(..., width = 2) worked for me as shown in the R document.

like image 57
camnesia Avatar answered Nov 11 '22 17:11

camnesia