Outputs

Webapplicaties bouwen met Shiny in R

Kaelen Medeiros

Data Scientist

Render-functies

ui <- fluidPage(
  textInput("name", "Enter a name:"),
  selectInput("animal", "Dogs or cats?", choices = c("dogs", "cats")),
  textOutput("question"),
  textOutput("answer")
)

server <- function(input, output, session) {
  output$question <- renderText({
    paste("Do you prefer dogs or cats,", input$name, "?")
  })
  output$answer <- renderText({
    paste("I prefer", input$animal, "!")
  })
}
Webapplicaties bouwen met Shiny in R

Andere render-functies

Webapplicaties bouwen met Shiny in R

Output-functies

ui <- fluidPage(
  textInput("name", "Enter a name:"),
  selectInput("animal", "Dogs or cats?", choices = c("dogs", "cats")),

textOutput("question"), textOutput("answer")
)
Webapplicaties bouwen met Shiny in R

Andere output-functies

  • tableOutput() of dataTableOutput
  • imageOutput()
  • plotOutput()
Webapplicaties bouwen met Shiny in R

Niet-Shiny output- en render-functies

library(shiny)
library(babynames)

ui <- fluidPage(
  DT::DTOutput("babynames_table")
)

server <- function(input, output){
  output$babynames_table <- DT::renderDT({
    babynames %>% 
      dplyr::slice_sample(prop = .1) %>%
      DT::datatable()
  })
}

shinyApp(ui = ui, server = server)

Een interactieve datatabel met een willekeurige 10% van de babynames-dataset

Webapplicaties bouwen met Shiny in R

Laten we oefenen!

Webapplicaties bouwen met Shiny in R

Preparing Video For Download...