I'm trying to make a new variable in my dataset called "total_cost" based on user inputs on the side bar.
What I would like to do is have a user go in, set a value for the numeric input for "Phase 1", "Phase 2" etc., then click "submit".
When they click submit, I would like for a reactive data table to show the variable they just made, in addition to the columns that were already there.
Like this:
Data Set Column 1 ; Data Set Column 2; Data Set Column 3; total_Cost.
Any help would be greatly appreciated as I'm a bit lost on how to make these data tables update based on user input. And the values in these data tables are critical for building the other graphics/charts/variables in my app.
library(shiny)
datatableforapp<-dataset %>% select(1-3)
ui <- fixedPage(
titlePanel("Title"),
sidebarLayout(
sidebarPanel( position = "left",
numericInput("Phase_1 ", "Phase 1 Cost",
value = 0, min = 0, max = 100),
numericInput("Phase_2 ", "Phase 2 Cost",,
value = 0, min = 0, max = 100),
numericInput("Phase_3", "Phase 3 Cost",
value = 0, min = 0, max = 100),
numericInput("Phase_4 ", "Phase 4 Cost",,
value = 0, min = 0, max = 100),
numericInput("Phase_5 ", "Phase 5 Cost",,
value = 0, min = 0, max = 100),
numericInput("Phase_6 ", "Phase 6 Cost",,
value = 0, min = 0, max = 100),
),
mainPanel(
tableOutput("table"),
tableOutput("table1"))))
server <- function(input, output, session) {
dynamic1 <- reactive({
dynamic1_num <- input$Phase_1 + input$Phase_2 + input$Phase_3 + input$Phase_4 + input$Phase_5 + +input$Phase_6
data.frame(dynamic1_num,datatableforapp)})
output$dynamic <- renderTable(dynamic)
output$dynamic1<- renderTable(dynamic1())}
# Run the application
shinyApp(ui = ui, server = server)