在Shiny应用程序启动时更改RStudio窗口大小

8
我正在使用RStudio IDE开发闪亮的应用程序。当启动应用程序时,我通常使用RunApp按钮:在窗口中运行。这将在具有特定宽度和高度的窗口中打开应用程序。
是否有一种方法可以更改此窗口的宽度,以便每次启动应用程序时都会显示在更宽的窗口中?

我也在寻找这个问题的解决方案。你有找到任何东西吗? - Cengover
1个回答

4

您可以尝试使用runGadget选项:

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")))

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接