reactiveValues from server.R to global.R in shiny R
Question
I am defining my variables (sdate
and edate
) as reactive values in global.R
global.R
sdate = reactiveValues()
edate=reactiveValues()
print(sdate)
print(edate)
I am getting start and end dates in server.R
output$daterange <- renderPrint({
assign('sdate', input$daterange[1], envir=.GlobalEnv)
assign('edate', input$daterange[2], envir=.GlobalEnv)
return(input$daterange)
})
I would like to use sdate
and edate
back in global.R to filter my data
df[df$Date>=sdate & df$Date<=edate,]
The error I am getting is
Error in NextMethod(.Generic) : (list) object cannot be coerced to type 'double'
Solution
I agree with Joe's comment: you should ony use global.R
to store some data and some functions, not to process something.
About your error message, a reactivevalues
object can be converted to an ordinary list
object with the reactiveValuesToList()
function.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow