I have a shinydashboard which displays the plots and boxes based on the data present in a single CSV file. I have scheduled the CSV to get updated for every 1 hour.But the shinydashboard isnt getting updated unless i refresh it manually or run it again(which is not ideal at all).
I have tried invalidatelater() but it doesnt seem to work.
Here is a small snippet.
server<-function(input,output,session){
`observe({
invalidateLater(60000,session)
isolate(Day<-read.csv("C:/Users/user1/Desktop/dashboardstuff/querycode.csv"))
})
querycode is the name of the CSV. This csv gets updated every 60 min and i want my dashboard to get updated as well. Not sure if this is the right way of doing it. Anyhelp would be appreciated.
Just to put up my code,
ui<-dashboardPage(
dashboardHeader(title = "METRIC DASHBOARD"),
dashboardSidebar(
useShinyjs(),
sidebarMenu(
id='tabs',
menuItem("NA DAY COUNT", tabName = "tab1") ,
menuItem("EU DAY COUNT", tabName = "tab2"),
menuItem("JA DAY COUNT", tabName = "tab3"),
menuItem("CUMULATIVE DAY COUNT", tabName = "tab4") ,
menuItem("EU DEFECTS SUBMITTED", tabName = "tab5"),
menuItem("NA DEFECTS SUBMITTED", tabName = "tab6") ,
menuItem("JA DEFECTS SUBMITTED", tabName = "tab7") ,
menuItem("Total DEFECTS SUBMITTED", tabName = "tab8"),
menuItem("HOURLY PRODUCTIVITY", tabName = "tab9") ,
menuItem("HOURLY DEFECTS SUBMITTED", tabName = "tab10")
)),
dashboardBody(
tabItems(
tabItem(
tabName = 'tab1',
highchartOutput("h1",height = 700)
),
tabItem(
tabName = 'tab2',
highchartOutput("h2",height = 700)
),
tabItem(
tabName = 'tab3',
highchartOutput("h3",height = 700)
),
tabItem(
tabName = 'tab4',
highchartOutput("h4",height = 700)
),
tabItem(
tabName = 'tab5',
highchartOutput("h5",height = 700)
),
tabItem(
tabName = 'tab6',
highchartOutput("h6",height = 700)
),
tabItem(
tabName = 'tab7',
highchartOutput("h7",height = 700)
),
tabItem(
tabName = 'tab8',
highchartOutput("h8",height = 700)
))
)
)
tabnames = c('tab1', 'tab2','tab3','tab4','tab5','tab6','tab7','tab8')
And here is the server part,
server<-function(input,output,session){
observe({
invalidateLater(60000,session)
isolate(Day<-read.csv("C:/Users/user1/Desktop/dashboardstuff/querycode.csv"))
})
# Day <- reactiveFileReader(60000*5,session,'C:/Users/pchintap/Desktop/dashboardstuff/querycode.csv',read.csv,header=TRUE)
# Day <- read.csv("C:/Users/user1/Desktop/dashboardstuff/querycode.csv")
# })
strptime(Day$review_started_timestamp,"%Y-%m-%d %H:%M:%S")+5*3600+30*60->Day$review_started_timestamp
substr(Day$review_started_timestamp,6,7)->Day$Month
substr(Day$review_started_timestamp,1,10)->Day$date
strftime(Day$date,format = "%V")->Day$Week
Day$Week<-as.factor(Day$Week)
substr(Day$review_started_timestamp,12,13)->Day$starthour
merge(Day,Associate.data%>%select("username","Q4.Manager","Project","Level","Q4.Shift","Region"),by.x = "username",all.x = TRUE)->Day
Day[complete.cases(Day),]->Day
output$h1<-renderHighchart({
hourNA<-Day
The rest of the code is just the data manipulation in the way i want it. But this is how i am trying to read the csv "Day". I have tried the methods mentioned in the comments. But it doesnt seem to work.