首页 > 解决方案 > 使用 RShiny 进行降价:全球环境的输入

问题描述

我想在输入中向用户询问一个数字,并在多个输出中使用它,以及在 HTML-Markdown 上的独立块中使用它。这意味着我想使用例如:

ui <- fluidPage(

    # "Number of Simulations"
    numericInput(inputId = "n",label = "Number of Simulations",
                 value = 100000,min = 1,max = 200000)

)

# Define server logic required to draw a histogram
server <- function(input, output) {

}

# Run the application 
shinyApp(ui = ui, server = server)

然后input$n在 ShinyApp 之外使用。有什么办法吗?也许我试图弄清楚的一种方法是:

ui <- fluidPage(

  # "Number of Simulations"
  numericInput(inputId = "n",label = "Number of Simulations",
               value = 100000,min = 1,max = 200000)

)

# Define server logic required to draw a histogram
server <- function(input, output) {
  reactive({
    setwd("C:/Users/alarc/OneDrive/Escritorio/Experimento")
    save(input$n,file = "brl.RData")
  })

}

# Run the application 
shinyApp(ui = ui, server = server)

但它不起作用。就像闪亮的应用程序无法读取该save功能一样。

标签: htmlrshinyr-markdownshinyapps

解决方案


推荐阅读