| Title: | Utillity Functions Used in sema.berlin Packages |
|---|---|
| Description: | This package provides utility functions that are used in sema.berlin.* packages. |
| Authors: | Hauke Sonnenberg [aut, cre] (ORCID: <https://orcid.org/0000-0001-9134-2871>), Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
| Maintainer: | Hauke Sonnenberg <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-06-04 09:20:42 UTC |
| Source: | https://github.com/KWB-R/sema.berlin.utils |
Compare Two Values Allowing a Tolerance
almost_equal(x, y, tolerance = 1e-06)almost_equal(x, y, tolerance = 1e-06)
x |
vector of numeric |
y |
vector of numeric |
tolerance |
tolerance, default: |
vector of logical
turn decimal number into string with comma
format_comma(x, nsmall = 0, ...)format_comma(x, nsmall = 0, ...)
x |
numeric vector |
nsmall |
number of digits to show |
... |
others |
Get Official BWB Colours
get_bwb_colours( full_info = FALSE, simple = TRUE, conditions = NULL, six = FALSE )get_bwb_colours( full_info = FALSE, simple = TRUE, conditions = NULL, six = FALSE )
full_info |
if |
simple |
if |
conditions |
optional. Vector of (four) condition names (best to worst)
to be used as the names of the returned vector of (four) colour codes.
|
six |
if |
# Get a colour vector get_bwb_colours() # Plot these colours plot_bwb_colours() # Check the decimal numbers by setting full_info to TRUE get_bwb_colours(full_info = TRUE) # Get six colours get_bwb_colours(six = TRUE)# Get a colour vector get_bwb_colours() # Plot these colours plot_bwb_colours() # Check the decimal numbers by setting full_info to TRUE get_bwb_colours(full_info = TRUE) # Get six colours get_bwb_colours(six = TRUE)
turn decimal number into string with comma
my_theme(...)my_theme(...)
... |
others arguments passed to 'ggplot2::theme()' |
Plot the BWB Colours in a Barplot
plot_bwb_colours(simple = TRUE)plot_bwb_colours(simple = TRUE)
simple |
passed to |
read csv file, e.g. variable rehab strategy or simulation results to compare
read_csv(file = NULL, dec)read_csv(file = NULL, dec)
file |
path to csv file |
dec |
decimal separator |
Remove All Substrings Matching the Pattern
str_remove_all(x, pattern)str_remove_all(x, pattern)
x |
vector of character |
pattern |
regular expression agains which the strings in |
x with elements in which substrings matching the
pattern are removed
Translate column names and categorical data
translate_data(df, translation_list)translate_data(df, translation_list)
df |
data to be translated |
translation_list |
list of names to be translated in format 'list(oldname1 = "newname1", oldname2 = "newname2", ...)' |
Sorted Unique Character Values
unique_sort_char(x)unique_sort_char(x)
x |
vector of objects that can be converted to a vector of character
with |
Replace Placeholders with Special Characters
use_spec_chars(x)use_spec_chars(x)
x |
vector of character |
write csv file, e.g. simulation result table
write_csv(data, outdir, filename, dec)write_csv(data, outdir, filename, dec)
data |
dataframe to be written |
outdir |
directory to save data |
filename |
filename to save data |
dec |
decimal separator |