Skip to content

Instantly share code, notes, and snippets.

@pbiecek
Created May 7, 2015 03:44
Show Gist options
  • Select an option

  • Save pbiecek/0617b36500f95daa3a00 to your computer and use it in GitHub Desktop.

Select an option

Save pbiecek/0617b36500f95daa3a00 to your computer and use it in GitHub Desktop.
ShinyExample
library(shiny)
library(PogromcyDanych)
# wykonywane raz gdy uruchamiana jest plikacja
serialeIMDB$sezon <- paste(serialeIMDB$sezon, serialeIMDB$odcinek, sep="/")
shinyServer(function(input, output) {
# reużywalny fragment
dane <- reactive({
serialeIMDB[serialeIMDB$serial == input$serial,
c("id", "serial", "nazwa", "sezon", "ocena", "glosow")]
})
# odpowiedź na kontrolki
output$tabela <- renderTable({
dane()
})
output$wykres <- renderPlot({
tmp <- dane()
ggplot(tmp, aes(x=id, y=ocena)) +
geom_point() + geom_smooth(se=FALSE)
})
output$podsumowanie <- renderPrint({
tmp <- dane()
summary(tmp[,c("ocena", "glosow")])
})
})
library(shiny)
library(PogromcyDanych)
shinyUI(fluidPage(
titlePanel("Eksplorator seriali"),
sidebarLayout(
sidebarPanel(
selectInput("serial",
"Wybierz serial",
levels(serialeIMDB$serial),
"Friends")
),
mainPanel(
p("Dane dotyczące wybranego serialu:"),
br(),
tabsetPanel(
tabPanel("Wykres", plotOutput("wykres", width = 500)),
tabPanel("Podsumowanie", verbatimTextOutput("podsumowanie")),
tabPanel("Tabela", tableOutput("tabela"))
)
)
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment