str_remove_decimals | R Documentation |
str_remove_decimals
is a function that for a character vector where
each element is a single word or number identifies all decimal numbers
(detected by a period .) and if the preceeding number of digits is larger
than one, i.e., the number in the text is >=10, then the decimals are removed
from the number. The intended use is to clean output to latex tables such
that decimals for large numbers are removed. It is important that the numbers
are stored in a single element in the string vector.
str_remove_decimals(string, pattern = NULL, n_digits = 2)
string |
Character string |
pattern |
Number pattern to look for |
n_digits |
Indicating how large the number must be before removing decimals. n_digits = 2 will remove decimals for numbers greater than or equal to 10, n_digits = 3 for numbers greater than or equal to 100 etc. |
Used in scripts: Robust function: TRUE
Character string with decimals removed for large numbers
## Not run:
str_remove_decimals("Hello, world 1,000.000")
str_remove_decimals("1.000")
str_remove_decimals("10.000")
str_remove_decimals("1,000.00")
str_remove_decimals(c("Hello, world", "1,000.00"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.