Description Usage Arguments Value Examples
View source: R/randomizeButton.R
Randomization is common to behavioral data collection. This action button allows you to supply a key-value pair of group and URL links for randomizing participants in a shiny application.
1 | randomizeButton(inputId, label, groupLinkPairs, addQueryParameter = TRUE, ...)
|
inputId |
Shiny input ID |
label |
The button label |
groupLinkPairs |
A data frame with two columns "group" and "link" containing the group and URL links for randomization. See examples for more details. |
addQueryParameter |
LOGICAL: TRUE and a query parameter "group_id" will be added to the randomization URL. FALSE and it won't. |
... |
Additional parameters to pass into |
The UI for an action button.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | keys <- data.frame(
group = c("A", "B"),
link = c("https://yourwebsite.com/this-task",
"https://yourwebsite.com/this-other-task")
)
if (interactive()) {
library(shiny)
ui <- fluidPage(
randomizeButton(inputId = "myId",
label = "Click me to randomize",
groupLinkPairs = keys,
addQueryParameter = TRUE)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.