Trigger a data refresh in shiny

0 votes

I have a shiny application that queries data from SQL into data frames, and then those data frames are referenced from my shinyServer() block. I've been running it only in RStudio thus far, and so whenever I needed new data I'd just restart the application and before the server loads it would grab all new data.

I'd like to transition the app to the shiny server, but I'm not sure how I can induce it to get new data periodically. For the sake of the interface, I'd like it to be automatic rather than have a user click a button to initiate the loading. Is there an idiomatic solution for this?

EDIT:

I think I found a solution that works for me.

shinyServer(function(input,output,session){
    sourceData <- reactive({
        invalidateLater(1000000,session)

        functionThatGetsData()
    })
})
May 31, 2018 in Data Analytics by DataKing99
• 8,240 points
4,292 views

1 answer to this question.

0 votes

You're looking for invalidateLater. Put this, with the appropriate interval, in the reactive expression that retrieves data from the database.

answered May 31, 2018 by Sahiti
• 6,370 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer

How to convert a list to data frame in R?

Let's assume your list of lists is ...READ MORE

answered Apr 12, 2018 in Data Analytics by nirvana
• 3,130 points

edited Apr 12, 2018 by nirvana 21,828 views
+1 vote
2 answers

How can I drop columns by name in a data frame ?

We can Drop Columns by name in ...READ MORE

answered Apr 14, 2018 in Data Analytics by zombie
• 3,790 points
28,053 views
0 votes
1 answer

How to drop factor levels in a subsetted data frame?

You can use factor(ff) to drop levels ...READ MORE

answered Apr 17, 2018 in Data Analytics by kappa3010
• 2,090 points

edited Apr 17, 2018 by kappa3010 5,029 views
0 votes
1 answer

How to refresh shiny dataset?

When you refresh the page in the ...READ MORE

answered May 31, 2018 in Data Analytics by Sahiti
• 6,370 points
1,643 views
0 votes
1 answer

Shiny app - tabs refresh content

Asha, It's very important to not add too ...READ MORE

answered Sep 24, 2019 in Data Analytics by Cherukuri
• 33,030 points
1,492 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
730 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
814 views
+1 vote
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
1,418 views
0 votes
2 answers

How to remove rows with missing values (NAs) in a data frame?

Hi, The below code returns rows without ...READ MORE

answered Aug 20, 2019 in Data Analytics by anonymous
• 33,030 points
14,405 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP