i want to take two select input boxes in which ...
first one will print the label like 'raj' and 'other' the second one will print the 30 names of the district when raj is clicked and 34 names of state when other is clicked. both raj and other and nothing but labels and this list of district and states will be fetched from ms SQL server as a stored procedure so i gotta use them as dtd$DistrictName and dtd2$StateName both are in the database, different queries that's why i stored them in different variables like dtd and dtd2. anyone knows how to print the dtd$DistrictName when label from select box 1 raj is clicked in other selectbox and same for another label named other
i don't know how to approach this problem, i have tried couple of code from the web and this is one of them but didn't work for me
library(RODBC)
library(RODBCext)
library(plotly)
library(shinydashboard)
library(tidyverse)
library(readr)
library(RODBC)
library(RODBCext)
library(shiny)
library(psych)
dbcnd <- odbcDriverConnect("Driver={SQL Server};Server=;Database=;Uid=;Pwd=''")
qrydd<<-paste("exec db..[sp_name] '0','0','','0','','01/01/2017','31/12/2017'")
qrydd
dtd <<- sqlQuery(dbcnd,qrydd)
dtd <<- data.frame(dtd)
dtd
qrydd2<<-paste("exec db..[sp_name]'','','','','0','0','2','0','','01/01/2017','31/12/2017'")
qrydd2
dtd2 <<- sqlQuery(dbcnd,qrydd2)
dtd2 <<- data.frame(dtd2)
dtd2
countyData = data.frame("raj"=dtd$DistrictName,"other_state"=dtd2$StateName,stringsAsFactors = FALSE)
ui = shinyUI(
fluidPage(
titlePanel("Reactive select input boxes"),
sidebarPanel(
htmlOutput("state"),
htmlOutput("district")
),
mainPanel(
plotOutput("plot1")
)
) )
server = shinyServer(function(input, output) {
output$state = renderUI({
selectInput(inputId = "raj",
label = "raj:",
choices = as.character(unique(countyData$raj)))
})
output$district = renderUI({
data_available = countyData[countyData$raj == input$raj, "other_state"]
selectInput(inputId = "other_state",
label = "other_state:",
choices = unique(data_available),
selected = unique(data_available)[1])
})
# output$plot1 = renderPlot({
# map('county', region = input$state)
#
# map('county', region =paste(input$state,input$county, sep=','),
# add = T, fill = T, col = 'red')
#
# })
})
shinyApp(ui = ui, server = server)