I'm doing an application in "Shiny" where I have a database, my problem is that when I enter the name of a drop-down list take that name, I look for it in a database and then I throw values associated with that name.
My database is called arcs
The character of the list is called places
This is how I call the value found.
input$places
This is how I would look if the city is Bogotá:
arcs$Bogotá
Throw a result vector, but I can not do it like this:
Data $(input$city)
I did an ifelse for each city (it works with 42, but not with the 1300 cities / municipalities that I have in Colombia)
############ Ui #################
# Define UI for application that draws a histogram
ui <- fluidPage(
#Header or Title Panel
titlePanel(title = h4("Inequity in Health Index - Colombia", align="center")),
selectInput("places", "Select city", c =(mylist),multiple = FALSE,"Angostura"),
mainPanel(
textOutput("city"),
tabPanel("viewUltimate1", plotOutput("viewUltimate1")),
tabPanel("viewUltimate2", plotOutput("viewUltimate2")),
submitButton("Refresh")
)
)
########### Server ###########
# Define server logic required to draw a histogram
server <- function(input, output) {
output$city <- renderText({as.character(input$places)})
cityPlot <- reactive({input$places})
################# Women #########################
output$viewUltimate1 <- renderPlot({
if(cityPlot()=="Referencia"){print(ggplot()+xlim(-1,1)+ylim(-1,1)+geom_arc_bar(aes(x0=0,y0=0,r0=0,
r=r<-as.numeric(arcs$Referencia),
start= arcs$deg1_women*pi/180, end= arcs$deg2_women*pi/180, fill = Variable, col = Variable),data=arcs,n=360,na.rm=FALSE,show.legend = TRUE) + labs(x = "Vector = AF, Angle=Weight", y ="")+ labs(title="Inequity in Health Index - Colombia - Women"))} else{...
# They are many more similar to this
}
}
})
print(r)
}
# Run the application
shinyApp(ui = ui, server = server)
Please Help