Informatyka ekonomiczna - wykład 5 (kierunek informatyka i ekonometria)

Wstęp do publikowania wyników w sposób interaktywny - biblioteka shiny

Jarosław Kotowicz

12 maja 2020r.

1 Przykładowe kody użyte w aplikacjach stworzonych z shiny

  1. Shiny Widgets Gallery
  2. Sliders
  3. pozostałe na stronie
library(shiny)
shinyApp(
  # Define UI for application that draws a histogram
ui <- fluidPage(
    # Application title
    titlePanel("Old Faithful Geyser Data"),
    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            sliderInput("bins",
                        "Number of bins:",
                        min = 1,
                        max = 50,
                        value = 30)
        ),
        # Show a plot of the generated distribution
        mainPanel(
           plotOutput("distPlot")
        )
    )
),
# Define server logic required to draw a histogram
server <- function(input, output) {
    output$distPlot <- renderPlot({
        # generate bins based on input$bins from ui.R
        x <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)
        # draw the histogram with the specified number of bins
        hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
}
)
LS0tDQp0aXRsZTogIkluZm9ybWF0eWthIGVrb25vbWljem5hIC0gd3lrxYJhZCA1IChraWVydW5layBpbmZvcm1hdHlrYSBpIGVrb25vbWV0cmlhKSINCnN1YnRpdGxlOiAiV3N0xJlwIGRvIHB1Ymxpa293YW5pYSB3eW5pa8OzdyB3IHNwb3PDs2IgaW50ZXJha3R5d255IC0gYmlibGlvdGVrYSBzaGlueSINCmF1dGhvcjogIkphcm9zxYJhdyBLb3Rvd2ljeiINCmRhdGU6ICIxMiBtYWphIDIwMjByLiINCm91dHB1dDoNCiAgaHRtbF9ub3RlYm9vazoNCiAgICBmaWdfY2FwdGlvbjogeWVzDQogICAgaGlnaGxpZ2h0OiBoYWRkb2NrDQogICAgbnVtYmVyX3NlY3Rpb25zOiB5ZXMNCiAgICB0aGVtZTogY2VydWxlYW4NCiAgICB0b2M6IHllcw0KcnVudGltZTogc2hpbnkNCi0tLQ0KDQojIFByenlrxYJhZG93ZSBrb2R5IHXFvHl0ZS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