1. The problem:
I am working with a sql data base, which is updated both by my shiny app and by another shiny app. I use df=isolate(reactivePoll ()) to be able to subset the dataframe, because reactivePoll generates a function as a result,however isolate() approach has a serious problem: it only updates the dataframe when the shiny app opens, it runs only once.
How can I update the dataframe object in real time and be able to subsett it? without the error: Error in: object of type 'closure' is not subsettable or Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
the reactivepoll function works very well inside a render function to show tables in real time, for example, but how do I update a data.frame in real time? being able to subset it df$col1 df$col2 etc?
server(input,output,session){
df=reactivePoll(intervalMillis = 2000,session, checkFunc = function(){
QUERY1= "SELECT * FROM table"
df_rs = dbSendQuery(storiesDb,QUERY1)
dbFetch(df_rs)},
valueFunc =function (){
QUERY1= "SELECT * FROM table"
df_rs = dbSendQuery(storiesDb,QUERY1)
dbFetch(df_rs)
} )
dataframe= isolate(df()) # this approach makes the dataframe update only when the shiny app open.
}
Attempts
1-I already tried to use dataframe=reactive({df ()}) but gives the error when i try to subset dataframe$col1: Error in: object of type 'closure' is not subsettable
2-I already tried to use dataframe=df () but gives the error: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)