Created
March 4, 2016 09:49
-
-
Save juananpe/526d56f79e4606df4200 to your computer and use it in GitHub Desktop.
Trying to understand how to use query parameters in Shiny
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(RMySQL) | |
source("keys.R") | |
con <- dbConnect( MySQL(), user=login, password=pass, db=database, host=host) | |
print(paste("Default:", groupId)) | |
res <- dbSendQuery(con, paste('SELECT user_id, user_name | |
FROM info i , enrolment e | |
where i.user_id = e.fk_user_id and e.fk_group_id = ', groupId)) | |
dataf <- dbFetch(res) | |
lista <- as.list(setNames(dataf$user_id, dataf$user_name)) | |
dbClearResult(res) | |
dbDisconnect(con) | |
ui <- fluidPage( column(3, checkboxGroupInput("users", | |
label = h3("User IDs"), | |
choices = lista, | |
selected = dataf$user_id), | |
verbatimTextOutput("value") | |
)) | |
server <- function(input, output, session) { | |
observe({ | |
groupId <- parseQueryString(session$clientData$url_search) | |
if ( length(groupId) > 0) { | |
print(paste("groupId:",groupId)) | |
}}) | |
} | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment