how to update the output dataframe from function depending on the UI user input

Dear All,
how to update the output data.frame "DF" values depending on the user input from shiny. so I want

  1. user to import values of Q1, Q2
  2. run the "mod0= function (Q1,Q2)
  3. result data.frame "C"
  4. how to make the new "DF" data.frame values update/react to the Q1,Q2 new values from shiny ui?

here is the code:
in ui.R I have:
numericInput("Q1", "Parking ", value= 1.2, min = 0, max = 1, step = 0.1),
numericInput("Q2", "ratio", value = 0.5,min = 0, max = 1, step = 0.1)

in server.R
I have:

mod0 = function(Q1,Q2){ #where Q1 and Q2 are numeric input in the shiny app ui

A= Q1+2
B=Q2+A
C <- data.frame(A,B)

return (C)
}

DF <- mod0(1,2)
DF
#> A B
#> 1 3 5
my question is how to update the DF values with the new values from shiny numeric input user interface?

I would really appreciate your help
Best Regards
Ahmed Ali
PhD candidate
Chung Ang University

I solved this problem by calling the C dataframe from the output function without giving values to mod0(1,2) as following

output$map <- renderLeaflet({
Q1 <- input$Q1
Q2 <- input$Q2

data.frame (mod0(Q1,Q2))
DF<- data.frame (mod0(Q1,Q2)) 

the user input of Q1 and Q2 in shiny directly update DF values
the process solved

  1. user to import values of Q1, Q2
  2. run the "mod0= function (Q1,Q2)
  3. result data.frame "C" #return(C)
    4.reactive "DF" data.frame values update/react to the Q1,Q2 new values from shiny ui

hope that helps you guys in the future

Hi @ahmedshingaly,

could you please mark this as solved even if it is your own solution.

Thanks

1 Like

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