output_text: Add dynamic text to a website

View source: R/output_text.R

output_textR Documentation

Add dynamic text to a website

Description

Adds a textual output based on the current state of input elements.

Usage

output_text(text, tag = "p", id = NULL, class = NULL, condition = NULL)

Arguments

text

A vector of text to be parsed; see details.

tag

Tag name of the element containing the text.

id

Unique ID of the output element.

class

Class names to add to the output's element.

condition

A conditional statement to decide visibility of the entire output element.

Details

Input References

text can include references to inputs by ID within curly brackets (e.g., "{input_id}").

Conditions

Multiple entries in text translate to separate elements. Each entry can be conditioned on a statement within curly brackets following an initial question mark (e.g., "?{input_a != 1}Input A is not 1"). If no statement is included after the question mark, the entry will be conditioned on a referred to input (TRUE if anything is selected).

Buttons

Embedded reset buttons can be specified within square brackets (e.g., "Reset[r input_id]"). Text before the brackets will be the button's display text, with multiple words included within parentheses (e.g., "(Reset Input A)[r input_a]"). If the text is a reference, this will be the default reset reference (e.g., "{input_a}[r]" is the same as "{input_a}[r input_a]").

Value

A character vector of the containing element of the text.

Examples

# text that shows the current value of `input_a`, and resets it on click
output_text("Selection: {input_a}[r]")

# adds a parenthetical if the value of the input is 0
output_text(c("Selection: {input_a}[r]", "?{input_a == 0}(input is zero)"))

uva-bi-sdad/community documentation built on Oct. 12, 2023, 1:18 p.m.