library(shiny)
# Define UI ----
ui <- fluidPage(
titlePanel("Liquid Recipe Calculator"),
sidebarLayout(position = "left",
sidebarPanel(
h3("Eingabe"),
numericInput("menge",
"zu erzeugende Menge (ml)",
value=50),
numericInput("nicbase",
"Nikotin in Base (mg/ml)",
value=20),
numericInput("nicwanted",
"gewünschte Nikotinmenge (mg/ml)",
value=2),
numericInput("flavor",
"Aromaanteil (%)",
value=20)
),
mainPanel(
h3("Rezept"),
tableOutput("rezeptoutput")
)
)
)
# Define server logic ----
server <- function(input, output) {
output$rezeptoutput <- renderTable({
data.frame(Zutat = c("Nikotin (ml)", "Base (ml)", "Aroma (ml)"),
Menge = c(input$menge * input$nicwanted / input$nicbase,
input$menge * ( 100 - input$flavor ) / 100 - ( input$menge * input$nicwanted / input$nicbase ),
input$menge * input$flavor / 100 )
)
})
}
# Run the app ----
shinyApp(ui = ui, server = server)