-1
I have this code for a Shiny app. Apparently there is no error in the code and when I select only the graph I can plot, but when I put to run the graph does not appear .
cat(getwd())
library(shiny)
library(leaflet)
library(tidyverse)
library(dplyr)
library(ggplot2)
dados <- ipeadata_taxa_desemprego_05_06_2018_10_39_
ui <- fluidPage(
titlePanel("Porcentagem de Pessoas Desempregadas por Estado"),
fluidRow(
selectInput("estado", label = ("Estado1"),
choices = list("NULL", "Acre" , "Alagoas", "Amapá", "Amazonas", "Bahia", "Ceará" , "Brasília" , "Espírito Santo", "Goiás", "Maranhão", "Mato Grosso do Sul" ,"Cuiabá", "Minas Gerais", "Pará", "Paraíba", "Paraná" , "Pernambuco", "Piauí", "Rio de Janeiro", "Rio Grande do Norte", "Rio Grande do Sul", "Rondônia", "Roraima", "São Paulo", "Santa Catarina", "Sergipe", "Tocantins"
),selected = "Acre"
)
)
)
mainPanel(
plotOutput("app")
)
server <- function(input, output) {
output$app <- renderPlot({
dados_plot <- dados %>%
select(., -Sigla, -Código, -X9) %>% ### tira as colunas que não vai precisar
filter(Estado == "input$estado") %>% ### seleciona o estado
gather("Anos", "Valor", 2:6) %>% ### transforma as colunas em linha
mutate("Anos" = as.factor(Anos)) ### trnasforma num fator
ggplot(dados_plot, aes(x = reorder(Anos,Valor), y = Valor, fill = Estado)) +
geom_bar(stat = "identity") + coord_flip() +
labs(x = "Anos", y = "Porcentagem (%)", title = "Estado")
})
}
# Run the application
shinyApp(ui = ui, server = server)
Welcome to Stackoverflow. Could you tell us the error message you receive? And also copy and paste the result of
dput(head(dados, 30))? Check out these and other tips how to improve your question.– Tomás Barcellos