I want to know the way to build a Shiny App which automatically runs functions in a scheduled time. I read this but it doesn't seem relevant to my case.
I created a function to update a google sheet, using the package googlesheet
. Now the app ui looks like this.
Clicking "Manually update" button enables the app to run the functions and update the googlesheet.
But I want the app to run the same function everyday at 1pm, even without clicking "Manually update" button, while "Activate auto update" button is on.
So to summarise, I want to know
- the way to automatically execute the functions at a scheduled time in shiny app.
- the way to save the user input of "Activate auto update". That is to say, once you turn on this button, even if you close this app and open it again, it stays to be "on". Once you turn off this button, it stays to be "off" until the user turn it on again, even if the user shuts off the app.
I'd appreciate for any kinds of help!
ui.R
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
server.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