rateServer | R Documentation |
Actions for likert scales
rateServer(
id = "rate",
trigger = NULL,
wait = 1,
type = c("button", "slider"),
n_scales = 1,
answer_all = FALSE,
choices = NULL,
instructions = "",
pretext = "",
scale_labs = NULL,
posttext = "",
direction = "horizontal",
sliderInit = 50,
sliderMin = 0,
sliderMax = 100,
pips = NULL,
step = 0.01
)
id |
The id of the module. Must be the same as the ID of |
trigger |
If not |
wait |
Integer. How long should we wait to display the scale(s) after the trigger event occurs? In milliseconds. |
type |
One of "button" or "slider". Must be the same as the |
n_scales |
Integer. The number of scales to be displayed on the page. Must match the value given in the corresponding call to |
answer_all |
If |
choices |
A list with length |
instructions |
Instructions that will appear at the top of the page. |
pretext |
Character. The text that will appear above the likert scale. |
scale_labs |
Character. The individual label that will appear above each scale if |
posttext |
Character. The text that will appear below the likert scale. |
direction |
Either "horizontal" or "vertical". Describes the position of the scale options (NOT the scales themselves) relative to each other. |
sliderInit |
Numeric. The starting value of the slider. Must be between |
sliderMin |
Numeric. The lower of the slider. Default is |
sliderMax |
Numeric. The upper limit of the slider. Default is |
pips |
List with two elements. Where to place numeric markers on the slider scale. See Details for more information. |
step |
Numeric. The distance between consecutive points (i.e., potential answers) on the slider. Default is |
Notes on sliders:
Consider carefully whether you need a slider. Do you expect participant responses to fall on a continuous scale in meaningful ways, or do you expect answers to fall in a number of blocks along the slider? If the latter, consider using a button scale as they are easier for participants to use (See Toepoel & Funke, 2018 and Chyung et al., 2018 (references below) for more information.).
Placing numeric markers along the scale and displaying the numeric response values are best for scales where the answer is truly numeric. (i.e., "How tall (in inches) do you think the talker in this recording is?") (See Gummer & Kunz, 2021 (reference below) for more information.)
The argument pips should be a list with 2 values: The first value, "density", indicates how far apart the minor divisions on the scale should be (e.g., density=5
will place a marker every 5 integers between sliderMin
and sliderMax
). The second element in the list, "values", is a vector denoting where the major breaks of the scale and their numeric labels should go (e.g., if values=c(0, 50, 100)
markers and numeric labels will be placed at 0, 50, and 100.) All values in values
must fall between sliderMin
and sliderMax
.
The default starting answer is in the center of the scale, as initializing the handle at the left of the scale has been shown to bias the answers towards the lower values. (CITE)
Currently, the rate*()
functions only support text values at the beginning and end of the slider. These will be placed inline with the slider and should represent the two extreme values (low and high, in that order). To place text at only one or the other extreme, just use an empty text string (""
) for the end of the scale where you do not wish to show a value.
Returns a reactive vector of the answers selected from each scale when the participant clicks submit.
Chyung, S. Y., Swanson, I., Roberts, K., & Hankinson, A. (2018). Evidence‐based survey design: The use of continuous rating scales in surveys. Performance Improvement, 57(5), 38-48.
Gummer, T., & Kunz, T. (2021). Using only numeric labels instead of verbal labels: Stripping rating scales to their bare minimum in web surveys. Social Science Computer Review, 39(5), 1003-1029.
Toepoel, V., & Funke, F. (2018). Sliders, visual analogue scales, or buttons: Influence of formats and scales in mobile and desktop surveys. Mathematical Population Studies, 25(2), 112-122.
if (interactive()){
library(shiny)
library(shinyjs)
ui <- fluidPage(
actionButton("btn", "Click me"),
rateUI(id = "example",
type = "button"),
actionButton("submit", "SUBMIT"),
textOutput("confirmation")
)
server <- function(input, output, session) {
rvs <- reactiveValues(rating = NULL)
observeEvent(input$btn, {
disable("btn")
rvs$ans <- rateServer(id = "example",
type = "button",
instructions = "What do you think?",
answers = c("Strongly disagree", "Disagree",
"Neutral", "Agree", "Strongly agree"),
pretext = "The vowels 'aw' and 'ah' sound exactly the same.")
})
observeEvent(input$submit, {
enable("btn")
output$confirmation <- renderText({
paste0("You selected ", rvs$ans$ratings[1],".")})
})
}
shinyApp(ui = ui, server = server)
}
# An example with 2 scales....
if (interactive()){
library(shiny)
library(shinyjs)
ui <- fluidPage(
actionButton("btn", "Click me"),
rateUI(id = "example",
type = "button",
n_scales = 2),
actionButton("submit", "SUBMIT"),
textOutput("confirmation")
)
server <- function(input, output, session) {
rvs <- reactiveValues(rating = NULL)
observeEvent(input$btn, {
disable("btn")
rvs$ans <- rateServer(id = "example",
trigger = NULL,
type = "button",
instructions = "Finish the sentence:",
answers = list(c("Sound completely the same",
"Sound similar, but not totally alike",
"Sound pretty different",
"Sound totally different"),
c("Are produced in the exact same way",
"Are produced similarly",
"Are produced pretty distinctly",
"Are produced in totally distinct ways")),
pretext = "The vowels 'aw' and 'ah'...",
n_scales = 2,
answer_all = TRUE,
direction = "vertical",
scale_labs = c("perception", "production"))
})
observeEvent(input$submit, {
enable("btn")
output$confirmation <- renderText({
paste0("You selected '", rvs$ans$ratings[1],"' and '", rvs$ans$ratings[2], "'.")})
})
}
shinyApp(ui = ui, server = server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.