shinyServer(function(input, output) {
  output$distPlot <- renderPlot({
 
    # mosaic setup
    require(mosaic); require(mosaicData)
    trellis.par.set(theme=theme.mosaic())
    # create new variable
    SAT = mutate(SAT, fracgrp = cut(frac, 
      breaks=c(0, 22, 49, 81), 
      labels=c("low fraction", "medium fraction", "high fraction")))
    # generate the desired plot
    if (input$stratify == "No") {
      xyplot(sat ~ salary, type=c("p", "r"), data=SAT)
    } else {
      xyplot(sat ~ salary, groups=fracgrp, auto.key=TRUE, 
        type=c("p", "r"), data=SAT)
    }
    })
  }
)
             
            
              library(shiny)
shinyUI(fluidPage(
  # Application title
  titlePanel("SAT scores and teacher salaries"),
  sidebarLayout(
    sidebarPanel(
      selectInput("stratify", "Stratify by percent taking SAT?",
                  choices = c("Yes", "No"), selected="No")),
    # Show a plot of the generated distribution
    mainPanel(plotOutput("distPlot"))
  )
))