shiny output messing up

Hello I don't understand why in my shiny app I cannot successfully output the matrix I have.
I ran the code in r out of the app to attest if the matrix is there :
image

here the error message,
image

I understand that the subscript is wrong somewhere but I don't know where
and here the code which is supposed to output the matrix :
In the UI :

tabPanel("Composition du portefeuille", dataTableOutput("poids"))

in the server :

 weight<-reactive({MAIN(input$Actifs,input$chxOpt,input$geom)})
output$poids<-DT::renderDataTable({weight()})

Main is the function that output the matrix perfectly fine in R alone
Please it's driving me crazy

you should debug your main function, i.e. observe what values are passed in via the input$ params, and understand how they behave in your function.

(Shiny debugging and reprex guide)

Hello thank you what can be done to inspect thing that are reactive ? like my inputs I can't get to see them :

Error: Can't access reactive value 'Actifs' outside of reactive consumer.
i Do you need to wrap inside reactive() or observer()?

Or :

Error: Operation not allowed without an active reactive context.
* You tried to do something that can only be done from inside a reactive consumer.
Run `rlang::last_error()` to see where the error occurred.

simply debug(Main) in your console before running the app, will drop you into a browser context whenever Main is called, and you will see what Main has received. (you will need to use console to undebug(Main) to drop that behaviour)
additionally where Main is called is a reactive context

weight<-reactive({MAIN(

so you could add code between the opening brace and main, to print things out, or browser.

I don't know what you attempted that gave you the can't access errors

1 Like

I figured it out !!!! Thanks a huge lot !! debugging is cool. Life is great

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.