Referring to reactive value outside of render() function

#1

Hello everyone,

I encountered a problem while writing a shiny App that I do not find a solution online for.

In the code snippet below, I know that I cannot refer to errors() without an reactive environment. However, if I include length(reactive({errors()[[1]]})) I get an error, whereas if I just use a number instead, the code works just fine. I would be very thankful for any pointers.

The error message is: Error in 1:reactive(length(errors()[[1]])) : NA/NaN argument

Here is a code snippet from the server.R:

lapply(1:length(errors()[[1]]), function(j) {
    output[[paste0('out',j)]] <- renderDataTable({
      datatable(data.table(Kommentar = "", errors()[[1]][[j]]), options = list(
        pageLength = 20,
        lengthMenu = c(5, 20, 50, 200))
      )
    })
  })

0 Likes