Description Usage Arguments Examples
Shiny module to create a non-coding exercise
1 2 3 | non_coding(input, output, session, feedback)
non_coding_ui(id)
|
input |
standard |
output |
standard |
session |
standard |
feedback |
a reactive that returns a named list with a message and feedback |
id |
id to call the module with |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ## Not run:
library(shiny)
num <- sample(1:10, 1)
check_exercise <- function(actual, guess){
if(actual == guess){
list(message = "Well Done!", success = TRUE)
} else {
msg <- sprintf("You guessed %s. Please try again!", guess)
list(message = msg, success = FALSE)
}
}
ui <- fluidPage(
theme = shinythemes::shinytheme('cosmo'),
titlePanel('Guess the Number'),
mainPanel(
sliderInput('num', 'Select number', 0, 10, 2),
non_coding_ui('feedback')
)
)
server <- function(input, output, session){
feedback <- reactive({
check_exercise(num, input$num)
})
shiny::callModule(non_coding, 'feedback', feedback)
}
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.