Learn R Programming

esmtools (version 1.0.1)

txt: Custom Text for Rmarkdown with Counting

Description

This function generates custom text and provides the option to include an optional count that can be integrated into the text. It creates an HTML span element with a unique identifier (ID). This identifier can be used for customizing the appearance of the text using CSS code. Default identifiers are "text_issue", "text_inspect", "text_mod". To use it, simply call the function within inline code, do not call this function within a chunk.

Usage

txt(
  id = "text_issue",
  title = "Issue",
  text = "",
  count = TRUE,
  output_file = NULL
)

Value

A character string containing the HTML span element with the specified ID and text.

Arguments

id

A character string specifying the unique identifier for the HTML span element. Default identifiers are "text_issue", "text_inspect", "text_mod".

title

A character string containing the text to display.

text

Descriptive text.

count

A logical value indicating whether to include a count in the text.

output_file

A character string specifying the json file should be created. If not provided, the template will be copied to the current working directory.

Examples

Run this code
if (interactive()) {
  # In RMarkdown, use 'r txt()`.
  # Do not call this function within a chunk

  txt("text_issue", "Issue", text = "Wrong participant number")
  txt("text_mod", "Modification", text = "Change the participant number from 1 to 32", 
      count = FALSE)
}

Run the code above in your browser using DataLab