Instantly share code, notes, and snippets.

Embed
What would you like to do?
Demo to show widget types, return values and data types in Shiny
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
})
}
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")
)
)
)
@rhamza

This comment has been minimized.

Show comment
Hide comment
@rhamza

rhamza commented Jun 21, 2014

thanks

@bluepill5

This comment has been minimized.

Show comment
Hide comment
@bluepill5

bluepill5 Nov 14, 2014

Good, thanks.

bluepill5 commented Nov 14, 2014

Good, thanks.

@whizzalan

This comment has been minimized.

Show comment
Hide comment
@whizzalan

whizzalan Feb 27, 2015

Appreciation for your link.

whizzalan commented Feb 27, 2015

Appreciation for your link.

@romunov

This comment has been minimized.

Show comment
Hide comment
@romunov

romunov Jul 26, 2015

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.

romunov commented Jul 26, 2015

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.

@bouasr

This comment has been minimized.

Show comment
Hide comment
@bouasr

bouasr Jun 7, 2017

Thanks...

bouasr commented Jun 7, 2017

Thanks...

@tamirbennatan

This comment has been minimized.

Show comment
Hide comment
@tamirbennatan

tamirbennatan Sep 16, 2017

Super helpful. Thanks

tamirbennatan commented Sep 16, 2017

Super helpful. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment