在 Shiny 应用程序启动时更改 RStudio 窗口的大小 [英] Change size of RStudio Window on start of Shiny app

查看:54
本文介绍了在 Shiny 应用程序启动时更改 RStudio 窗口的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 RStudio IDE 开发闪亮的应用程序.启动应用程序时,我通常使用 RunApp 按钮:在窗口中运行.这会在具有特定宽度和高度的窗口中打开应用.

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?

推荐答案

你可以试试 runGadget 选项:

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

这篇关于在 Shiny 应用程序启动时更改 RStudio 窗口的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆