Package 'sema.berlin.utils'

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

Help Index


Compare Two Values Allowing a Tolerance

Description

Compare Two Values Allowing a Tolerance

Usage

almost_equal(x, y, tolerance = 1e-06)

Arguments

x

vector of numeric

y

vector of numeric

tolerance

tolerance, default: 1e-6

Value

vector of logical


turn decimal number into string with comma

Description

turn decimal number into string with comma

Usage

format_comma(x, nsmall = 0, ...)

Arguments

x

numeric vector

nsmall

number of digits to show

...

others


Get Official BWB Colours

Description

Get Official BWB Colours

Usage

get_bwb_colours(
  full_info = FALSE,
  simple = TRUE,
  conditions = NULL,
  six = FALSE
)

Arguments

full_info

if TRUE, a data frame with columns approx_name, red, green, blue, value is returned. The column approx_name contains the "approximate name" of the colour, as found by http://chir.ag/projects/name-that-color). By default, this argument is set to FALSE in which case a named vector containing only the "#rrggbb" strings is returned.

simple

if TRUE (the default) only the main colours with clear names (blue, green, yellow, orange, red) are returned

conditions

optional. Vector of (four) condition names (best to worst) to be used as the names of the returned vector of (four) colour codes. FALSE.

six

if TRUE six colours from dark green to dark red are returned. The default is FALSE.

Examples

# 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

Description

turn decimal number into string with comma

Usage

my_theme(...)

Arguments

...

others arguments passed to 'ggplot2::theme()'


Plot the BWB Colours in a Barplot

Description

Plot the BWB Colours in a Barplot

Usage

plot_bwb_colours(simple = TRUE)

Arguments

simple

passed to get_bwb_colours


read csv file, e.g. variable rehab strategy or simulation results to compare

Description

read csv file, e.g. variable rehab strategy or simulation results to compare

Usage

read_csv(file = NULL, dec)

Arguments

file

path to csv file

dec

decimal separator


Remove All Substrings Matching the Pattern

Description

Remove All Substrings Matching the Pattern

Usage

str_remove_all(x, pattern)

Arguments

x

vector of character

pattern

regular expression agains which the strings in x are matched

Value

x with elements in which substrings matching the pattern are removed


Translate column names and categorical data

Description

Translate column names and categorical data

Usage

translate_data(df, translation_list)

Arguments

df

data to be translated

translation_list

list of names to be translated in format 'list(oldname1 = "newname1", oldname2 = "newname2", ...)'


Sorted Unique Character Values

Description

Sorted Unique Character Values

Usage

unique_sort_char(x)

Arguments

x

vector of objects that can be converted to a vector of character with as.character


Replace Placeholders with Special Characters

Description

Replace Placeholders with Special Characters

Usage

use_spec_chars(x)

Arguments

x

vector of character


write csv file, e.g. simulation result table

Description

write csv file, e.g. simulation result table

Usage

write_csv(data, outdir, filename, dec)

Arguments

data

dataframe to be written

outdir

directory to save data

filename

filename to save data

dec

decimal separator