| Title: | Utilities for Describing and Comparing Data |
|---|---|
| Description: | Provides functionality that assists in tabular description and statistical comparison of data. |
| Authors: | Andreas Leha [aut], Fabian Kück [aut, cre] |
| Maintainer: | Fabian Kück <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0 |
| Built: | 2026-05-16 06:33:09 UTC |
| Source: | https://github.com/cran/descutils |
Computes the number of decimal places in the character representation of a number.
decimalplaces(x)decimalplaces(x)
x |
A character string representing a number. |
Integer: The number of digits after the decimal point; 0 if there is no decimal point.
decimalplaces("3.141") # returns 3 decimalplaces("42") # returns 0decimalplaces("3.141") # returns 3 decimalplaces("42") # returns 0
Code from Dirk Eddelbuettel via Stackoverflow (https://stackoverflow.com/a/15569373/1844418)
difftime_years(t2, t1)difftime_years(t2, t1)
t2 |
end time of the interval. Will be coerced to Date |
t1 |
starting time of the interval. Will be coerced to Date |
numeric. t2 - t1 [years]
Andreas Leha
difftime_years("2003-04-05", "2001-01-01")difftime_years("2003-04-05", "2001-01-01")
English text version of number
digits2text(x, mult = "")digits2text(x, mult = "")
x |
number to convert |
mult |
to be appended (like a unit) |
Converts a number to a text version of that number
character
Graham Williams [email protected] https://rattle.togaware.com/utility.R
Formats a numeric vector similar to formatC, but tweaks output for certain special cases:
- Attempts to remove trailing decimal points for whole numbers.
- If format is 'fg' and output is "0", falls back to fixed format (f).
- Converts exponential notation to plain numbers where appropriate.
formatC_mod(x, digits = NULL, format = NULL, ...)formatC_mod(x, digits = NULL, format = NULL, ...)
x |
A numeric vector. |
digits |
Integer; desired number of digits. |
format |
Character string specifying the output format; see |
... |
Further arguments passed to |
A character vector with formatted numbers.
formatC_mod(c(3.14159, 42, 0), digits = 2, format = "fg") formatC_mod(c(1e-6, 42), digits = 2, format = "fg")formatC_mod(c(3.14159, 42, 0), digits = 2, format = "fg") formatC_mod(c(1e-6, 42), digits = 2, format = "fg")
wrapper around quantile() and format() and paste().
formatIQR(x, digits = 2, significant_digits = TRUE, ...)formatIQR(x, digits = 2, significant_digits = TRUE, ...)
x |
vector to be summarized |
digits |
Integer specifying the number of digits to display. Default is 2. |
significant_digits |
Logical. If |
... |
passed onto quantile() as well as to format(). meant for arguments |
character.
Dr. Andreas Leha
Print a text for English prosa
makeEnglishList(v, sep = ", ", lastsep = ", and ", onlysep = " and ")makeEnglishList(v, sep = ", ", lastsep = ", and ", onlysep = " and ")
v |
vector |
sep |
character. spearates all but last entries of |
lastsep |
character. spearates the last entries of |
onlysep |
character. spearates the two entries of |
Pastes a vector and adds comma and "and" to the correct places
character with plain text English prosa version
Andreas Leha
## defaut separators makeEnglishList(c("foo", "bar", "baz")) makeEnglishList(c("foo", "bar")) makeEnglishList(c("foo")) ## without the 'Oxford comma' makeEnglishList(c("foo", "bar", "baz"), lastsep = " and ") ## an 'or' list makeEnglishList(c("foo", "bar", "baz"), lastsep = ", or ")## defaut separators makeEnglishList(c("foo", "bar", "baz")) makeEnglishList(c("foo", "bar")) makeEnglishList(c("foo")) ## without the 'Oxford comma' makeEnglishList(c("foo", "bar", "baz"), lastsep = " and ") ## an 'or' list makeEnglishList(c("foo", "bar", "baz"), lastsep = ", or ")
Given 0.56 and 1.22998 this will return [0.56; 1.23].
prettyCI(conf.low, conf.high, digits = 2)prettyCI(conf.low, conf.high, digits = 2)
conf.low |
numeric vector. lower limits of the (confidence) interval |
conf.high |
numeric vector of the same length of |
digits |
numeric. number of digits to round the limits to |
character of the form "[conf.low; conf.high]"
Dr. Andreas Leha
prettyCI(0.56, 1.22998)prettyCI(0.56, 1.22998)
Pretty print number
prettyNumbers(vals, digits = 5)prettyNumbers(vals, digits = 5)
vals |
numeric |
digits |
how many significant digits to print |
character vector of pretty printed numbers
Fabian Kück
Pretty print p-values
prettyPvalues( p_vals, digits = 5, signiflev = 0.05, lhs = NULL, lhs_sep = "=", orgbold = TRUE, roundonly = FALSE )prettyPvalues( p_vals, digits = 5, signiflev = 0.05, lhs = NULL, lhs_sep = "=", orgbold = TRUE, roundonly = FALSE )
p_vals |
numeric |
digits |
how many digits to print |
signiflev |
print in bold face if smaller than this |
lhs |
character. left hand side of the printed 'formula'. Defaults to NULL, in which case neither lhs nor lhs_sep will be printed. |
lhs_sep |
character. Separator between lhs and pretty pvalue. Defaults to "<". |
orgbold |
boolean. Surround significant p values by '*'?. Defaults to TRUE. |
roundonly |
boolean. if TRUE, do neiter prepend any number with '<' nor do enclose any number with '*'. Defaults to FALSE |
Pretty print p-values with org-mode syntax for bold face
character vector of pretty printed p-values
Andreas Leha
wrap all elements in a vector in quotes (or other strings)
wrapQuote(v, quoteChr = "'", endquoteChr = NULL)wrapQuote(v, quoteChr = "'", endquoteChr = NULL)
v |
vector of elements to wrap |
quoteChr |
character. to be put around of the elements of
|
endquoteChr |
character or NULL (default). If not NULL
|
character vector of the elements of v wrapped
between quotes
Andreas Leha
## default behaviour: wrap in single quotes wrapQuote(1:10) ## change to wrap in asterisks wrapQuote(1:10, "*") ## different front from back quotes wrapQuote(1:10, "*", "/") ## you can also wrap with longer strings wrapQuote(1:10, "quote")## default behaviour: wrap in single quotes wrapQuote(1:10) ## change to wrap in asterisks wrapQuote(1:10, "*") ## different front from back quotes wrapQuote(1:10, "*", "/") ## you can also wrap with longer strings wrapQuote(1:10, "quote")