Overview of the functionality provided by the dynutils package

Robrecht Cannoodt & Wouter Saelens

Table of contents

Manipulation of lists

add_class: Add a class to an object

extend_with: Extend list with more data


calculate_distance: Compute pairwise distances between two matrices

See ?calculate_distance for the list of currently supported distances.

For euclidean distances, this is similar to calculating:

project_to_segments: Project a set of points to to set of segments

calculate_mean: Calculate a (weighted) mean between vectors or a list of vectors; supports the arithmetic, geometric and harmonic mean

Manipulation of matrices

expand_matrix: Add rows and columns to a matrix

Scaling of matrices and vectors

scale_uniform: Rescale data to have a certain center and max range

Generate a matrix from a normal distribution with a large standard deviation, centered at c(5, 5).

Center the dataset at c(0, 0) with a minimum of c(-.5, -.5) and a maximum of c(.5, .5).

Check the ranges and verify that the scaling is correct.

scale_minmax: Rescale data to a [0, 1] range

Check the ranges and verify that the scaling is correct.

scale_quantile: Cut off outer quantiles and rescale to a [0, 1] range

Check the ranges and verify that the scaling is correct.

Manipulation of functions

inherit_default_params: Have one function inherit the default parameters from other functions

Manipulation of packages

check_packages: Easily checking whether certain packages are installed

install_packages: Install packages taking into account the remotes of another

This is useful for installing suggested packages with GitHub remotes.

> install_packages("SCORPIUS", package = "dynmethods", prompt = TRUE)
Following packages have to be installed: SCORPIUS
Do you want to install these packages? (y/yes/1 or n/no/2): 1
Installing SCORPIUS
** testing if installed package can be loaded
Installed SCORPIUS

Manipulation of character vectors

random_time_string: Generates a string very likely to be unique

Tibble helpers

list_as_tibble: Convert a list of lists to a tibble whilst retaining class information

tibble_as_list: Convert a tibble back to a list of lists whilst retaining class information

extract_row_to_list: Extracts one row from a tibble and converts it to a list

mapdf: Apply a function to each row of a data frame

The mapdf functions apply a function on each row of a data frame. They are based heavily on purrr’s map functions.

Or use an anonymous function.

Or even a formula.

There are many more variations available. See ?mapdf for more info.

File helpers

safe_tempdir: Create an empty temporary directory and return its path

Assertion helpers

%all_in%: Check whether a vector are all elements of another vector

%has_names%: Check whether an object has certain names

is_single_numeric: Check whether a value is a single numeric

is_bounded: Check whether a value within a certain interval