1

我想知道如何构建一个在预定时间自动运行功能的 Shiny App。我读了这个,但它似乎与我的情况无关。

我创建了一个函数来更新谷歌表,使用包googlesheet。现在应用程序 ui 看起来像这样。

在此处输入图像描述

单击“手动更新”按钮使应用程序能够运行功能并更新 googlesheet。

但我希望应用程序每天下午 1 点运行相同的功能,即使没有单击“手动更新”按钮,而“激活自动更新”按钮处于打开状态。

所以总结一下,我想知道

  1. 在闪亮的应用程序中在预定时间自动执行功能的方式。
  2. 保存“激活自动更新”的用户输入的方式。也就是说,一旦你打开了这个按钮,即使你关闭了这个应用程序再打开它,它也一直处于“开启”状态。关闭此按钮后,即使用户关闭了应用程序,它也会一直处于“关闭”状态,直到用户再次打开它。

我会很感激任何帮助!

用户界面

navbarPage("Automated Report Generator", id = "nav",

           tabPanel("ITM",
                    sidebarLayout(
                      sidebarPanel(materialSwitch(inputId = "activateAutoITM", 
                                                  label = "Activate auto update", 
                                                  status = "primary", right = FALSE),
                                   actionButton("ITM_update", "Manually update"),
                               width = 2),
                  mainPanel(div(a("Visit ITM Google Sheet",
                                  href = "https://docs.google.com/spreadsheets/d/#########",
                                  target="_blank")),
                            div(htmlOutput("gsheet_text_ITM"))
                ) 
                ) # sidebarLayout
            )) # navbarPage

服务器.R

shinyServer(function(input, output, session) {

  observeEvent(input$ITM_update, {

    ####### Here are the functions to update google sheet########
    ####### But I'll just omit because of the security#########

    output$gsheet_text_ITM <- renderUI({
          str1 <- paste("Calculation finised.")
          HTML(paste(str1))
    })
  }) # shinyServer
4

0 回答 0