library(shiny)
library(dplyr)
library(ggplot2)
library(cea20160329)
ui <- shinyUI(fluidPage(
titlePanel("Olá, Shiny!"),
sidebarLayout(
sidebarPanel(
checkboxInput(inputId = 'smooth',
label = 'Smooth?',
value = FALSE),
radioButtons(inputId = 'ano',
label = 'Ano',
choices = c(1991, 2000, 2010),
selected = '2010')
),
mainPanel(
plotOutput("distPlot"),
tableOutput('tab')
)
)
))
server <- shinyServer(function(input, output) {
output$distPlot <- renderPlot({
dados <- pnud %>%
filter(ano == as.numeric(input$ano))
p <- ggplot(dados, aes(x=idhm_l, y=idhm_e, size=idhm_r)) +
geom_point(alpha = 0.1, colour = 'darkgreen') +
theme_bw()
if(input[['smooth']] == TRUE) {
p <- p + geom_smooth()
}
print(p)
})
output$tab <- renderTable({
dados <- pnud %>%
filter(ano == as.numeric(input$ano))
dados %>%
select(starts_with('idhm')) %>%
cor()
})
})
shinyApp(ui = ui, server = server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.