Блестящая проблема с реактивным значением проконсультируйтесь по Матрице - PullRequest
0 голосов
/ 31 октября 2018

Я делаю приложение в «Блестящем», где у меня есть база данных. Я выбираю имя из выпадающего списка, ищу его в базе данных и затем выбрасываю значения, связанные с этим именем.

Моя база данных называется Data. Список символов называется «местами».

Вот как я называю найденное значение: input$places

Вот как бы я выглядел, если бы город был Богота: Data$Bogotá

Я хочу выбросить вектор результата, но я не могу сделать это так:

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_womenpi/180, end= arcs$deg2_womenpi/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
         }
       }
     })
    ################# Men #########################
    output$viewUltimate2 <- renderPlot({

  if(cityPlot()=="Referencia"){      
     print(ggplot()+xlim(-1,1)+ylim(-1,1)+geom_arc_bar(
     aes(x0=0,y0=0,r0=0,
     r=r1<- as.numeric(arcs1$Referencia),start=arcs1$deg1_men*pi/180, end = 
     arcs1$deg2_men*pi/180, fill = arcs1$Variable, col = arcs1$Variable),  
     data = arcs1, n = 360, na.rm = FALSE, show.legend = TRUE) +    labs(x = 
     "Vector=AF,Angle=Weight",y="")+labs(title="Inequity in Health Index - 
     Colombia - Men"))} else{...
    }
   }
######## They are many more similar to this

    })  
    print(r)
}

######## Run the application
shinyApp(ui = ui, server = server)
...