mysql - R, Shiny ,应用程序之前的弹出窗口

标签 mysql r shiny

我正在开发一个 Shiny 的应用程序,它在启动时访问 MySQL 服务器并从中提取大量数据。此数据稍后会在应用程序的使用过程中被过滤。

由于传输的数据量很大,第一个查询需要很长时间,这就是为什么我想创建一个对话框/弹出窗口或类似的东西,在应用程序启动时打开,并让用户选择“预过滤器”的设置,例如仅 2017 年 3 月的数据。

这可能吗?如果可以,该怎么做?到目前为止,我没有找到任何关于它的信息。

最佳答案

这是实现您想要的目标的一种方法。您只需在服务器函数中执行 showModal(modalDialog()) 即可在启动时显示弹出窗口。有了这些知识,使用 reactiveValobserveEvent 就可以非常简单地获得您想要的结果。

希望对您有所帮助!

library(shiny)
library(dplyr)

ui <- fluidPage(
      dataTableOutput('my_table'),
      actionButton('change','Change query')
)

server <- function(input,output,session)
{
  # the modal dialog where the user can enter the query details.
  query_modal <- modalDialog(
    title = "Important message",
    selectInput('input_query','Select # cyl:',unique(mtcars$cyl)),
    easyClose = F,
    footer = tagList(
      actionButton("run", "Run query")
    )
  )

  # Show the model on start up ...
  showModal(query_modal)

  # ... or when user wants to change query
  observeEvent(input$change,
               {
                 showModal(query_modal)
               })

  # reactiveVal to store the dataset
  my_dataset <- reactiveVal()

  observeEvent(input$run, {
    removeModal()

    # Your query here
    my_data <- mtcars %>% filter(cyl %in% input$input_query)
    my_dataset(my_data)

  })

  # render the output
  output$my_table <- renderDataTable(my_dataset())

}

shinyApp(ui,server)

关于mysql - R, Shiny ,应用程序之前的弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50326110/

相关文章:

css - 一些右对齐的 tabPanels Shiny

php - 使用可滚动条 Jquery 限制返回结果

mysql - 获取 mysql 中 JSON 数组元素的索引

r - 使用 visNetwork R 包的类似思维导图的布局(使用 vis.js javascript 库的网络可视化)

从 R 中的数据框中删除重复的列组合

r - 上传,转换xlsx文件和下载结果 Shiny

button - 在 Shiny 的情况下,我如何使用操作按钮的值更新输入文本字段

php - 使用 PDO 语句选择表数据

mysql - 数据库结构 : Would this structure work with this m:m?

r - 嵌套函数是否更慢?