autoRandomize: Automatically randomize the URL for every visitor

Description Usage Arguments Value Examples

View source: R/autoRandomize.R

Description

Automatically randomize the URL for every visitor

Usage

1
autoRandomize(groupLinkPairs, addQueryParameter = TRUE)

Arguments

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.

Value

NA; used for side effects

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
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# An example of a static website where the `task_url` parameter can be passed
# in as a character string.

if (interactive()) {

  library(shiny)
  library(shinyland)

  ui <- fluidPage(
    shinyland(
      navbar_title = "{shinyland} presents",
      task_title = "A demo task",
      description_text = make_description(
        rawHTML = TRUE,
        '
       <div class = "col-sm-3 box mx-4 p-4 text-center">
       This is an example for creating a landing page.
       This is where a description of the text would go.
       </div>
      '),
      informed_consent_text = make_informed_consent(
        rawHTML = FALSE,
        tags$div("This is an example for creating a landing page.
               This is where Informed Consent language would go.
               In this case, clicking 'Yes, I agree to participate'
               will redirect you to the website https://jdtrat.com."
        )
      ),
      task_url = "https://jdtrat.com"
    )
  )

  server <- function(input, output, session) {

  }

  shinyApp(ui, server)

}

# An example of a landing page that will randomize the URL only when the
# cloud computer re-runs the app after a dormant period.

if (interactive()) {

  library(shiny)
  library(shinyland)

  # Create a data frame of group-link pairs.
  group_link_pairs <- data.frame(
    group = c("personal", "github"),
    link = c("https://jdtrat.com/",
             "https://github.com/jdtrat")
  )

  ui <- fluidPage(
    shinyland(
      navbar_title = "{shinyland} presents",
      task_title = "A demo task",
      description_text = make_description(
        rawHTML = TRUE,
        '
       <div class = "col-sm-3 box mx-4 p-4 text-center">
       This is an example for creating a landing page.
       This is where a description of the text would go.
       </div>
      '),
      informed_consent_text = make_informed_consent(
        rawHTML = FALSE,
        tags$div("This is an example for creating a landing page.
               This is where Informed Consent language would go.
               In this case, clicking 'Yes, I agree to participate'
               will redirect you to the website https://jdtrat.com."
        )
      ),
      task_url = shinyrandomize::random_link(groupLinkPairs = group_link_pairs)
    )
  )

  server <- function(input, output, session) {

  }

  shinyApp(ui, server)

}


# An example of a landing page that will update whenever a user visits the
# landing page. Note the use of the server here. This is the recommended
# practice to ensure randomization.

if (interactive()) {

  library(shiny)
  library(shinyland)

  # Create a data frame of group-link pairs.
  group_link_pairs <- data.frame(
    group = c("personal", "github"),
    link = c("https://jdtrat.com/",
             "https://github.com/jdtrat")
  )

  ui <- fluidPage(
    shinyland(
      navbar_title = "{shinyland} presents",
      task_title = "A demo task",
      description_text = make_description(
        rawHTML = TRUE,
        '
       <div class = "col-sm-3 box mx-4 p-4 text-center">
       This is an example for creating a landing page.
       This is where a description of the text would go.
       </div>
      '),
      informed_consent_text = make_informed_consent(
        rawHTML = FALSE,
        tags$div("This is an example for creating a landing page.
               This is where Informed Consent language would go.
               In this case, clicking 'Yes, I agree to participate'
               will redirect you to the website https://jdtrat.com."
        )
      ),
      task_url = "https://website-does-not-matter-because-it-will-be-replaced.com"
    )
  )

  server <- function(input, output, session) {
    autoRandomize(groupLinkPairs = group_link_pairs)
  }

  shinyApp(ui, server)

}

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