Learn R Programming

exams.forge (version 1.0.10)

replace_fmt: Replace

Description

In a text it replaces names with:

  • values which are formatted with exams::fmt(), or

  • strings

Usage

replace_fmt(txt, digits = 2L, ...)

Value

A character with replaced names.

Arguments

txt

character: text where the replacement is done

digits

numeric or list: number of digits to round

...

names to replace with values

Examples

Run this code
replace_fmt("\\frac{x}{y}", x=2, y=3)
replace_fmt("\\frac{x}{y}", x=2, y=3, digits=0)
replace_fmt("\\frac{x}{y}", x=2, y=3, digits=list(0))
replace_fmt("\\frac{x}{y}", x=2, y=3, digits=list(2, y=0))
replace_fmt("\\frac{x}{y}", x="\\\\sum_{i=1}^n x_i", y="\\\\sum_{i=1}^n y_i")

Run the code above in your browser using DataLab