str_remove_decimals_all | R Documentation |
str_remove_decimals_all
is a function that for a character vector
where each element is a string with multiple words or numbers 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. The input here is typically the output from stargazer
.
str_remove_decimals_all(string, pattern = NULL, split_pattern = NULL, n_digits)
string |
Character vector |
pattern |
Number pattern to look for |
split_pattern |
Pattern to split each element of string vector by. This argument should ensure that each number stored in each string element is isolated by itself. In latex output, this is achieved by & |
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: FALSE
Character vector with strings where decimals are removed for large numbers
## Not run:
str_remove_decimals_all(c("Hello & 1,000.000", "My text"))
str_remove_decimals_all("Hello; 10.000", "1.000 is low")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.