Examples of Shiny output functions

tableOutput()

dataTableOutput()

imageOutput()

plotOutput()

verbatimTextOutput()


            

textOutput()

show with app
library(shiny)
library(ggplot2)

# save an image if it doesn't already exist
# if (!"plot.png" %in% list.files()) {
#   png("plot.png")
#   plot(mtcars$wt, mtcars$mpg)
#   dev.off()
# }

ui <-
  fluidPage (
    column(
      
      h3("Examples of Shiny output functions"),
      
      h4("tableOutput()"),
      tableOutput("table"),
      
      h4("dataTableOutput()"),
      dataTableOutput("datatable"),
      
      h4("imageOutput()"),
      # default height of imageOutput() is 400px
      imageOutput("image", height = 480),
      
      h4("plotOutput()"),
      plotOutput("plot"),
      
      h4("verbatimTextOutput()"),
      verbatimTextOutput("vtext"),
      
      h4("textOutput()"),
      textOutput("text"),

    width = 8)
  )

server <-
  function(input, output) {
    output$table <- renderTable({mtcars})
    
    output$datatable <- renderDataTable({mtcars})
    
    output$image <- renderImage({list(src = "uw_crest.png")}, deleteFile = F)
    
    output$plot <- renderPlot({ggplot(mtcars, aes(wt, mpg)) + geom_point()})
    
    output$vtext <- renderPrint({"Hello."})
    
    output$text <- renderText({"Hello again."})
  }


shinyApp(ui = ui, server = server, options = list(display.mode = "showcase"))