16

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

5
  • I think you can't. I remember I've read somewhere it's related to bootstrap settings (which is used by shiny) where the width of the sidebar is 4 units and the main panel one is 8 units. I'm afraid you will need to switch to fluidRow + column and do some hand-made design. Dec 15, 2017 at 15:51
  • I see - In that case i'll go about this the manual way and edit it into the question as another way I attempted this for future reference Dec 15, 2017 at 15:56
  • 1
    Have you considered using flexdashboard? rmarkdown.rstudio.com/flexdashboard/shiny.html - that allows to control sidebar width
    – dww
    Dec 15, 2017 at 16:01
  • Yeah, it looks very good! Dec 15, 2017 at 16:08
  • I've never touched flexdashboard (this is my first ever shiny project) so i will have to learn it before I can update on if i can get what I'm after - thanks for pointing it out Dec 15, 2017 at 16:23

1 Answer 1

27

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.