在 Shiny 应用程序启动时更改 RStudio Window 的大小
Change size of RStudio Window on start of Shiny app
我正在使用 RStudio IDE 开发闪亮的应用程序。启动应用程序时,我通常使用 运行应用程序按钮:Window 中的 运行。这将在具有特定宽度和高度的 window 中打开应用程序。
有没有办法改变这个window的宽度,所以每次我启动应用程序时都会显示得更宽window?
您可以试试 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")))
我正在使用 RStudio IDE 开发闪亮的应用程序。启动应用程序时,我通常使用 运行应用程序按钮:Window 中的 运行。这将在具有特定宽度和高度的 window 中打开应用程序。
有没有办法改变这个window的宽度,所以每次我启动应用程序时都会显示得更宽window?
您可以试试 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")))