View source: R/add_rating_input.R
raterInput | R Documentation |
Widget Rater pour Shiny
raterInput( inputId, label, initial_value, step_size, max_value, width = NULL, style = "" )
inputId |
id de l'input |
label |
label |
initial_value |
valeur initiale |
step_size |
pas entre 2 valeurs |
max_value |
valeur maximale |
width |
largeur du widget |
style |
style css |
un widget shiny
https://github.com/auxiliary/rater/
## Not run: library(shiny) library(shinyYM) ui <- fluidPage( sidebarLayout( sidebarPanel( actionButton(inputId = "addone", "Ajouter 1 étoile"), actionButton(inputId = "substractone", "Retirer 1 étoile"), verbatimTextOutput("resultat1"), verbatimTextOutput("resultat2") ), mainPanel( raterInput("exemple1", label = "exemple1", initial_value = 1, step_size = .5, max_value = 10), raterInput("exemple2", label = "exemple2", initial_value = 4, step_size = 1, max_value = 8, style = "font-size: 35px; color : gold;") ) ) ) server <- function(input, output, session) { output$resultat1 <- renderPrint(input$exemple1) output$resultat2 <- renderPrint(input$exemple2) observeEvent(input$addone, { updateRaterInput(inputId = "exemple1", value = pmin(10, input$exemple1 + 1), session = session) updateRaterInput(inputId = "exemple2", value = pmin(8, input$exemple2 + 1), session = session) }) observeEvent(input$substractone, { updateRaterInput(inputId = "exemple1", value = pmax(0, input$exemple1 - 1), session = session) updateRaterInput(inputId = "exemple2", value = pmax(0, input$exemple2 - 1), session = session) }) } shinyApp(ui = ui, server = server) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.