Last active
October 2, 2019 15:55
-
-
Save ChrisBeeley/6571951 to your computer and use it in GitHub Desktop.
Demo to show widget types, return values and data types in Shiny
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(input, output) { | |
output$textDisplay <- renderTable({ | |
getMat = matrix( | |
c(paste(input$checkGroup, collapse=','), class(input$checkGroup), | |
input$boxInput, class(input$boxInput), | |
as.character(as.Date(input$theDate, origin = "1970-01-01")), class(input$theDate), | |
paste(as.character(as.Date(input$dateRange[[1]], origin = "1970-01-01")), | |
as.character(as.Date(input$dateRange[[2]], origin = "1970-01-01")), | |
collapse = ','), | |
class(input$dateRange), | |
input$pickNumber, class(input$pickNumber), | |
input$pickRadio, class(input$pickRadio), | |
input$comboBox, class(input$comboBox), | |
input$slider, class(input$slider), | |
input$comment, class(input$comment) | |
), ncol = 2, byrow = TRUE) | |
colnames(getMat) = c("Value", "Class") | |
getMat | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fluidPage( | |
titlePanel("Widget values and data types"), | |
sidebarLayout( | |
sidebarPanel( | |
checkboxGroupInput(inputId = "checkGroup", | |
label = "1. checkboxGroupInput", | |
choices = list("Ice cream" = "IC", "Trifle" = "Trifle", | |
"Pistachios" = "Pist")), | |
checkboxInput(inputId = "boxInput", | |
label = "2. checkboxInput"), | |
dateInput(inputId = "theDate", | |
label = "3. dateInput"), | |
dateRangeInput(inputId = "dateRange", | |
label = "4. dateRangeInput"), | |
numericInput(inputId = "pickNumber", | |
label = "5. numericInput", | |
min = 1, max = 10, value = 1), | |
radioButtons(inputId = "pickRadio", | |
label = "6. radioButtons", | |
choices = list("Taxi" = "Taxi", "Take a walk" = "Walk")), | |
selectInput(inputId = "comboBox", | |
label = "7. selectInput", | |
choices = list("News" = "News", "Situation comedy" = "Sitcom", "Film" = "Film")), | |
sliderInput(inputId = "slider", | |
label = "8. sliderInput", | |
min = 1, max = 10, value = 7, step = 1), | |
textInput(inputId = "comment", | |
label = "9. textInput", | |
value = "") | |
), | |
mainPanel( | |
h3("Output and data type"), | |
tableOutput("textDisplay") | |
) | |
) | |
) |
Appreciation for your link.
I made a crossbreed app between what you have and widget gallery on rstudio's website. Mainly because I was pissed at how implicit the docs are about how to access values input by user without making a reproducible example for every widget added.
Thanks...
Super helpful. Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good, thanks.