Skip to content
Snippets Groups Projects
Commit 18f490ca authored by Mahendra Mariadassou's avatar Mahendra Mariadassou
Browse files

Ajout d'un exemple simple de reactivité

parent 61d5db3e
No related branches found
No related tags found
No related merge requests found
Pipeline #87753 passed with stage
in 59 seconds
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
# Define UI for application that compute A^2 + B^2
ui <- fluidPage(
# Application title
titlePanel("Illustration for reactlog"),
# Sidebar with two numeric inputs
sidebarLayout(
sidebarPanel(
numericInput(inputId = "A", label = "Choose first integer (A)", value = 3, min = 0, max = 10, step = 1),
numericInput(inputId = "B", label = "Choose second integer (B)", value = 4, min = 0, max = 10, step = 1)
),
# Text and verbatim outputs
mainPanel(
textOutput("C_text"),
verbatimTextOutput("C_verbatim")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
A2 <- reactive({ input$A^2}, label = "A^2")
B2 <- reactive({ input$B^2}, label = "B^2")
C2 <- reactive({ A2() + B2() }, label = "C^2")
C <- reactive({
paste0("A^2 + B^2 is equal to ", C2(), ".")
}, label = "C")
output$C_text <- renderText({
C()
})
output$C_verbatim <- renderPrint({
C()
})
}
# Run the application
shinyApp(ui = ui, server = server)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment