0

Getting the Error in : object of type 'closure' is not subsettable error when trying to use slickR to output a slideshow for multiple inputs, how can I solve this?

  observeEvent(input$imagepreview, {
output$x <- renderImage({
  if (is.null(input$picture))
    return(NULL)

  if (input$picture == "Round Eye") {
    return(list(
      src = "images/roundeye.jpg",
      filetype = "image/jpeg",
      alt = "Face"
    ))
  }else if (input$picture == "Wayfarer" && input$arm == "Red" && input$body == "Yellow") {
  return(
    
    output$slickR <- renderSlickR({
    imgs <- list.files("C:/", pattern=".jpg", full.names = TRUE)
    slickR(imgs)
  })
)
}
else if (input$picture == "Square" && input$arm == "Blue" && input$body == "Green") {
  return(list(
    src = "images/wayfarercustom.jpg",
    filetype = "image/jpeg",
    alt = "This is a chainring"
  ))
}

}, deleteFile = FALSE) })

  • 1
    "In general this error message means that you have tried to use indexing on a function" from https://stackoverflow.com/questions/11308367/error-in-my-code-object-of-type-closure-is-not-subsettable – Damian Apr 13 '21 at 20:48
  • 1
    Please provide a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), in this case the smallest running shiny app that reproduces your problem. The error message usually is raised in shiny when you use a `reactive` value without the round brackets, e.g. you need `my_reactive_value()`. Also, it is not good style to define reactive outputs within an `observeEvent` – starja Apr 13 '21 at 20:58

0 Answers0