Skip to content

Instantly share code, notes, and snippets.

@juananpe
Created March 4, 2016 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juananpe/526d56f79e4606df4200 to your computer and use it in GitHub Desktop.
Save juananpe/526d56f79e4606df4200 to your computer and use it in GitHub Desktop.
Trying to understand how to use query parameters in Shiny
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