ui <- fluidPage(
# Application title
titlePanel("DLR"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
selectInput("var",
label = "Choose a Station-id",
choices = list("ALNMRGA1"='a', "COOKOLV1"='b', "COOKOLV3"='c',"DRSS1ST1"='c',"GSHTEM1"='d',"GSWSILM"='e',"GSCFTY1"='f',"GSD5531"='g',"GSHASET"='h',"GSHTEM2"='i',"GSNPRM1"='j',"GSOAKSK1"='k',"ROSSLEX1"='l',"OR_Ln60_1"='n',"COOKOLV2"='o'),
selected = "ALNMRGA1"),
selectInput("dynamic",
label = "Choose a Attribute",
choices = c("Temperature" = "a1",
"windspeed" = "a2",
"DLR_value"="a3"),
selected = "DLR_value"),
dateRangeInput('dateRange',
label = 'Date range input: yyyy-mm-dd',
start = Sys.Date() - 2, end = Sys.Date() + 2
),
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
submitButton("Submit") ),
# Show a plot of the generated distribution
mainPanel(
plotOutput("dateText")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output,session) {
output$dateText<- renderPlot({
conn <-dbConnect(odbc(),
Driver="SQL Server",
Server ="abc",
Database = "test")
if(input$var=='a'&&input$dynamic=='a1'){
x<-dbGetQuery(conn, paste0("SELECT top 100 temperature FROM tblWeatherGWC WHERE validDateTime >='",input$dateRange[1]," 00:00:00.000'" ,"AND validDateTime <= '",input$dateRange[2]," 00:00:00.000' and stationId='ALNMRGA-1'"))
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x$temperature ,col = 'red', border = 'white',breaks = bins)
}} ) }
# Run the application
shinyApp(ui = ui, server = server)
I want that my code to directly take values of station_id from the database and all the other attributes from the database instead of describing them and writing them in the slider menu. I want the input and display data according to that.