Skip to content

Instantly share code, notes, and snippets.

@haozhu233
Created October 4, 2015 06:56
Show Gist options
  • Save haozhu233/e107c761b62a14e04735 to your computer and use it in GitHub Desktop.
Save haozhu233/e107c761b62a14e04735 to your computer and use it in GitHub Desktop.
a question on so
library(shiny)
shinyServer(
function(input, output) {
x <- data.frame(PRODUCT=factor(c("ALPHA", "ALPHA","BRAVO","ALPHA","ALPHA")),
YYYYMM= factor(c("2/1/2015","3/1/2015","4/1/2015","5/1/2015","6/1/2015")),
COUNT=c(44,22,37,76,97))
## select only rows where PRODUCT = input$product
x1 <- reactive({
x[ ( x$PRODUCT == input$product | input$product == "all") , ]
})
output$pr <- renderText(input$product)
output$chart <- renderPlot({
#hist(x$COUNT)
hist(x1()$COUNT)
})
})
library(shiny)
library(rCharts)
shinyUI(fluidPage(
titlePanel("Count Report "),
h4("This application shows product data"),
sidebarLayout(
sidebarPanel(
selectizeInput("product","Product:",c("ALPHA","BRAVO","all"), selected="all")
),
mainPanel(
h4("Chart "),
h4(textOutput("pr")),
plotOutput("chart")
)
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment