View source: R/ltx_round_numbers.R
ltx_round_numbers | R Documentation |
This function takes a LaTeX table with numerical data and rounds numbers based on a specified threshold. Numbers greater than or equal to the threshold will be rounded to a specified number of decimal places (big_dec), while numbers below the threshold will be rounded to a different number of decimal places (small_dec).
ltx_round_numbers(
latex_table,
threshold = 10,
big_dec = 0,
small_dec = 2,
print_tbl = FALSE
)
latex_table |
A character vector, data frame, or matrix representing a LaTeX table. The function will round numerical values within the LaTeX code. |
threshold |
A numeric value that determines the cutoff for rounding.
Numbers greater than or equal to this value will be rounded to |
big_dec |
An integer indicating the number of decimal places to round to for numbers greater than or equal to the threshold. Default is 0. |
small_dec |
An integer indicating the number of decimal places to round to for numbers below the threshold. Default is 2. |
print_tbl |
A logical flag indicating whether the modified table should
be printed to the console and copied to the clipboard. Defaults to |
A character vector representing the modified LaTeX table with rounded numbers.
## Not run:
latex_table <- c(
"\\begin{tabular}{|c|c|c|}",
"\\hline",
"Value A & Value B & Value C \\\\",
"\\hline",
"1.234 & 10.5678 & 12345.6789 \\\\",
"2.345 & 9.8765 & 6789.0123 \\\\",
"\\hline",
"\\end{tabular}"
)
rounded_table <- ltx_round_numbers(latex_table, threshold = 10)
print(rounded_table)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.