server.R 869 B

12345678910111213141516171819202122232425262728293031323334
  1. # This is the server logic for a Shiny web application.
  2. # You can find out more about building applications with Shiny here:
  3. #
  4. # http://shiny.rstudio.com
  5. #
  6. library(shiny)
  7. shinyServer(function(input, output) {
  8. output$distPlot <- renderPlot({
  9. # generate bins based on input$bins from ui.R
  10. x <- faithful[, 2]
  11. bins <- seq(min(x), max(x), length.out = input$bins + 1)
  12. # draw the histogram with the specified number of bins
  13. hist(x, breaks = bins, col = 'darkgray', border = 'white')
  14. })
  15. # 向用户界面输出iris数据表,根据input$n输出行数
  16. output$mytable <- renderTable({
  17. head(iris,input$n)
  18. })
  19. # 用用户界面输出箱线图,并根据input$outliers是否输出异常点
  20. output$myplot <- renderPlot({
  21. boxplot(Sepal.Length~Species,data=iris,
  22. col=rainbow(3),outline = input$outliers)
  23. })
  24. })