I am working on a dashboard that will automatically refresh every 30 minutes.
The idea is to automatically execute a function every 30 minutes, save the output in csv file, and then plot a graph based on the csv file generated.
After 30 minutes, do it all over again. This time the graph should be based on the latest csv file generated.
(I am still working on retrieving new datasets from SQL, let's focus on this part first)
The dashboard framework is almost done. But I couldn’t figure out how to make it rerun the function every 30 minutes to display the latest outcome.
Is there any way to execute the function periodically, and then plot graph based on the latest output? I tried taskscheduler but it didn’t work.
I have written the code so that the outcome will be exported to csv file and the file is named with the time stamp (for record purpose). Meaning every 30 minutes a new file will be generated. How can I plot graph based on that newly generated csv file?
data_frame <- data.frame (
x = c(5, 7, 9, 14, 15),
y = c(6, 8, 10, 16, 4)
)
function_a <- function(x,y){
a<- x*y
return(a)
}
output<-function_a(data_frame, data_frame)
str1<-'function_test.csv'
write.csv(output, file = paste0(sub('\\..*', ' ', str1), format(Sys.time(),'%d_%m__%H_%M'), '.csv'))
fig <- plot_ly(output, x = ~x, y = ~y,
name = 'Measured COD', type = 'scatter', mode = 'lines+markers',
line = list(color = 'rgb(205, 12, 24)', width = 2))
fig <- fig %>% layout(title = "Effluent COD",
xaxis = list(title = "Days"),
yaxis = list (title = "Concentration (mg/L)"))
fig
This is just an example of simple function that I am playing around with to test which method may work.
Helps are very much appreciated!