Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change size of RStudio Window on start of Shiny app

Tags:

r

rstudio

shiny

I'm using the RStudio IDE to develop shiny apps. When starting an app I usually use the RunApp Button: Run in Window. This opens the app in a window with specific width and height.

Is there a way to change the width of this window, so every time I start the app will be shown in a wider window?

like image 830
needRhelp Avatar asked Feb 27 '17 17:02

needRhelp


1 Answers

You can try the runGadget option:

library(shiny)

ui <- fluidPage(
  titlePanel("Hello Shiny!"),
  sidebarLayout(
    sidebarPanel(sliderInput(inputId = "bins", label = "Number of bins:", min = 1, max = 50, value = 30)),
    mainPanel(plotOutput(outputId = "distPlot"))
  )
)

server <- function(input, output) {
  output$distPlot <- renderPlot({
    x    <- faithful$waiting
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    hist(x, breaks = bins, col = "#75AADB", border = "white",
         xlab = "Waiting time to next eruption (in mins)",
         main = "Histogram of waiting times")
    })
}

# Run in a dialog within R Studio
runGadget(ui, server, viewer = dialogViewer("Dialog Title", width = 1200, height = 600))

# Run in Viewer pane
runGadget(ui, server, viewer = paneViewer(minHeight = 500))

# Run in browser
runGadget(ui, server, viewer = browserViewer(browser = getOption("browser")))
like image 144
Matt_B Avatar answered Nov 15 '22 06:11

Matt_B