randomizeButton: Action Button that Sends Users to Different Locations

Description Usage Arguments Value Examples

View source: R/randomizeButton.R

Description

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.

Usage

1
randomizeButton(inputId, label, groupLinkPairs, addQueryParameter = TRUE, ...)

Arguments

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 shiny::actionButton()

Value

The UI for an action button.

Examples

 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)


}

jdtrat/shinyrandomize documentation built on Dec. 20, 2021, 10:06 p.m.