【问题标题】:R-Shiny ApplicationR-闪亮应用
【发布时间】:2021-08-16 22:09:25
【问题描述】:

我正在尝试构建一个闪亮的应用程序,用户可以通过闪亮的应用程序输入日期,然后触发 R 脚本来利用该日期。
我想知道如何将来自闪亮的日期输入链接到 R 脚本中?

function(input, output) {
  # You can access the value of the widget with input$date, e.g.
  output$value <- renderPrint({ input$date })
}

【问题讨论】:

  • 您可以将您的 R 脚本代码放入一个以日期为参数的函数中,或者只是将脚本重写为 Shiny 应用程序中的一系列反应函数。你需要脚本做什么?

标签: r shiny


【解决方案1】:

这是一个最小的工作示例:

library(shiny)

ui <- fluidPage(
    dateRangeInput("date","Date:"),
    textOutput("value")
)

server <- function(input, output) {
    output$value <- renderPrint({ 
        x <- input$date
        # script using x goes here
        paste("choice:",x[1],"to",x[2]) # example output
        })
}
 
shinyApp(ui = ui, server = server)

【讨论】:

    猜你喜欢
    • 2019-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-16
    • 2016-12-20
    • 2017-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多