cacheKeyExpr related error

Hi to All,
This script having some errors. I am unable to find a solution.

ui <- dashboardPage(
dashboardHeader(title = "GI"),
dashboardSidebar(
selectInput("plots", "Select Option:",choices=list("Daily","HR","Monthly"), multiple = TRUE)

),

dashboardBody(
box(fluidRow(uiOutput("plot")),solidHeader = T, collapsible = T,status = "primary", closable =TRUE, width = 1000)

))

server <- function(input, output, session) {

output$Daily<- renderCachedPlot({
query <- parseQueryString(session$clientData$url_search)
value <- as.numeric(paste(names(query),query))
if("Daily" %in% input$plots){
require(ggplot2)
Colors = c("Average"="Black", "P1"= "Red", "P2" = "Blue", "P3"= "Magenta")
p <- ggplot(data.frame(average[,value])) +
geom_line(aes(seq(1,24), average[,value], color = "Average"), group = 1) +
geom_line(aes(seq(1,24), p1[,value], color = "P1"), group = 1) +
geom_line(aes(seq(1,24), p2[,value], color = "P2"), group = 1) +
geom_line(aes(seq(1,24), p3[,value], color = "P3"), group = 1) +
geom_ribbon(aes(x = seq(1:24), ymax = max[,value], ymin = min[,value]),group =1, fill = "skyblue", alpha = 0.5)+ scale_x_continuous(expand = c(0, 0),limits = c(1,24)) + scale_y_continuous(expand = c(0, 0),limits = c(0,1100))+ xlab("Hours") + ylab("radi")+
theme(panel.background = element_rect(fill='white'),panel.grid.major = element_line(size = 0.1, linetype = 'solid',colour = "grey"),axis.line = element_line(colour = "grey"),
panel.border = element_rect(colour = "grey", fill=NA, size=0.2),plot.background = element_rect(fill='transparent'),axis.title =element_text(color ="Black", face ="bold", size =12),axis.text = element_text(color = "black", size = 8))+ scale_color_manual(values = Colors)

   ggplotly(p) %>% 
   layout(legend = list( x = 0,y = 1))
   
   }
  },
**cacheKeyExpr = { value },**

)

Warning: Error in reactive:userCacheKey: object 'value' not found

I think its becayse value isnt defined in the scope you are using it.
I wonder whether

would work as the cache key for you instead.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.