Hello, I am trying to create a selectInput drop down option in my app. However, I want to drop down options to be the observations from my local dataset (extracted through POSTREGSQL). Any helpful ideas? I would really appreciate it.
Currently, I have the selectInput in my ui file and I also have the following pieces in my server file:
sqltrial <- function(){
con <- dbConnect(dbDriver('PostgreSQL'),
user='------',
password='-------',
dbname='--------',
host = '--------',
port = '------')
sqlOutputRootId <- reactive ({
sqlInputRootId <- paste("select distinct ROOTID from TABLE")
dbGetQuery(con, sqlInputRootId)
})
}
observe ({
updateSelectInput(session,"pickrootidd","Root ID",
choices = sqlOutputRootId())
})
Should choices be sqltrial instead?
I am not sure what the observe does? And, in the sqltrial function I create the connection. Then, I create the connection later as well when I write my query for the output. In that query I use the paste function and "input$pickrootidd" in the blank that I want to fill with the input. Do I need to create the connection twice? Can I just write the connection lines once after these lines (or do I have to embed it in a function like I currently do above in the function sqltrial?):
session <-
shinyServer(function(input, output){
I am getting the errors:
Warning: Error in as.vector: cannot coerce type 'closure' to vector of type 'list'
Warning: Error in : object of type 'closure' is not subsettable
Thank you very much!