Title: | Common Functionality for the 'dynverse' Packages |
---|---|
Description: | Provides common functionality for the 'dynverse' packages. 'dynverse' is created to support the development, execution, and benchmarking of trajectory inference methods. For more information, check out <https://dynverse.org>. |
Authors: | Robrecht Cannoodt [aut, cre] (<https://orcid.org/0000-0003-3641-729X>, rcannood), Wouter Saelens [aut] (<https://orcid.org/0000-0002-7114-6248>, zouter) |
Maintainer: | Robrecht Cannoodt <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.11 |
Built: | 2024-11-11 05:46:29 UTC |
Source: | https://github.com/dynverse/dynutils |
Add class to object whilst keeping the old classes
add_class(x, class)
add_class(x, class)
x |
a R object |
class |
A character vector naming classes |
library(purrr) l <- list(important_number = 42) %>% add_class("my_list")
library(purrr) l <- list(important_number = 42) %>% add_class("my_list")
Check whether a vector are all elements of another vector
all_in(x, table) x %all_in% table
all_in(x, table) x %all_in% table
x |
The values to be matched. |
table |
The values to be matched against. |
## Not run: library(assertthat) assert_that(c(1, 2) %all_in% c(0, 1, 2, 3, 4)) # TRUE assert_that("a" %all_in% letters) # TRUE assert_that("A" %all_in% letters) # Error: "A" is missing 1 element from letters: "A" assert_that(1:10 %all_in% letters) # Error: 1:10 is missing 10 elements from letters: 1L, 2L, 3L, ... ## End(Not run)
## Not run: library(assertthat) assert_that(c(1, 2) %all_in% c(0, 1, 2, 3, 4)) # TRUE assert_that("a" %all_in% letters) # TRUE assert_that("A" %all_in% letters) # Error: "A" is missing 1 element from letters: "A" assert_that(1:10 %all_in% letters) # Error: 1:10 is missing 10 elements from letters: 1L, 2L, 3L, ... ## End(Not run)
Anything outside the range of [0, 1] will be set to 0 or 1.
apply_minmax_scale(x, addend, multiplier)
apply_minmax_scale(x, addend, multiplier)
x |
A numeric vector, matrix or data frame. |
addend |
A minimum vector for each column |
multiplier |
A scaling vector for each column |
The scaled matrix or verctor. The numeric centering and scalings used are returned as attributes.
Anything outside the range of [0, 1] will be set to 0 or 1.
apply_quantile_scale(x, addend, multiplier)
apply_quantile_scale(x, addend, multiplier)
x |
A numeric vector, matrix or data frame. |
addend |
A minimum vector for each column |
multiplier |
A scaling vector for each column |
The scaled matrix or vector. The numeric centering and scalings used are returned as attributes.
Apply a uniform scale
apply_uniform_scale(x, addend, multiplier)
apply_uniform_scale(x, addend, multiplier)
x |
A numeric vector, matrix or data frame. |
addend |
A centering vector for each column |
multiplier |
A scaling vector for each column |
The centered, scaled matrix. The numeric centering and scalings used are returned as attributes.
These matrices can be dense or sparse.
calculate_distance( x, y = NULL, method = c("pearson", "spearman", "cosine", "euclidean", "chisquared", "hamming", "kullback", "manhattan", "maximum", "canberra", "minkowski"), margin = 1, diag = FALSE, drop0 = FALSE ) list_distance_methods() calculate_similarity( x, y = NULL, margin = 1, method = c("spearman", "pearson", "cosine"), diag = FALSE, drop0 = FALSE ) list_similarity_methods()
calculate_distance( x, y = NULL, method = c("pearson", "spearman", "cosine", "euclidean", "chisquared", "hamming", "kullback", "manhattan", "maximum", "canberra", "minkowski"), margin = 1, diag = FALSE, drop0 = FALSE ) list_distance_methods() calculate_similarity( x, y = NULL, margin = 1, method = c("spearman", "pearson", "cosine"), diag = FALSE, drop0 = FALSE ) list_similarity_methods()
x |
A numeric matrix, dense or sparse. |
y |
(Optional) a numeric matrix, dense or sparse, with |
method |
Which distance method to use. Options are: |
margin |
integer indicating margin of similarity/distance computation. 1 indicates rows or 2 indicates columns. |
diag |
if |
drop0 |
if |
## Generate two matrices with 50 and 100 samples library(Matrix) x <- Matrix::rsparsematrix(50, 1000, .01) y <- Matrix::rsparsematrix(100, 1000, .01) dist_euclidean <- calculate_distance(x, y, method = "euclidean") dist_manhattan <- calculate_distance(x, y, method = "manhattan") dist_spearman <- calculate_distance(x, y, method = "spearman") dist_pearson <- calculate_distance(x, y, method = "pearson") dist_angular <- calculate_distance(x, y, method = "cosine")
## Generate two matrices with 50 and 100 samples library(Matrix) x <- Matrix::rsparsematrix(50, 1000, .01) y <- Matrix::rsparsematrix(100, 1000, .01) dist_euclidean <- calculate_distance(x, y, method = "euclidean") dist_manhattan <- calculate_distance(x, y, method = "manhattan") dist_spearman <- calculate_distance(x, y, method = "spearman") dist_pearson <- calculate_distance(x, y, method = "pearson") dist_angular <- calculate_distance(x, y, method = "cosine")
This function supports the arithmetic, geometric and harmonic mean.
calculate_mean(..., method, weights = NULL) calculate_harmonic_mean(..., weights = NULL) calculate_geometric_mean(..., weights = NULL) calculate_arithmetic_mean(..., weights = NULL)
calculate_mean(..., method, weights = NULL) calculate_harmonic_mean(..., weights = NULL) calculate_geometric_mean(..., weights = NULL) calculate_arithmetic_mean(..., weights = NULL)
... |
Can be:
|
method |
The aggregation function. Must be one of |
weights |
Weights with the same length as |
calculate_arithmetic_mean(0.1, 0.5, 0.9) calculate_geometric_mean(0.1, 0.5, 0.9) calculate_harmonic_mean(0.1, 0.5, 0.9) calculate_mean(.1, .5, .9, method = "harmonic") # example with multiple vectors calculate_arithmetic_mean(c(0.1, 0.9), c(0.2, 1)) # example with a list of vectors vectors <- list(c(0.1, 0.2), c(0.4, 0.5)) calculate_geometric_mean(vectors) # example of weighted means calculate_geometric_mean(c(0.1, 10), c(0.9, 20), c(0.5, 2), weights = c(1, 2, 5))
calculate_arithmetic_mean(0.1, 0.5, 0.9) calculate_geometric_mean(0.1, 0.5, 0.9) calculate_harmonic_mean(0.1, 0.5, 0.9) calculate_mean(.1, .5, .9, method = "harmonic") # example with multiple vectors calculate_arithmetic_mean(c(0.1, 0.9), c(0.2, 1)) # example with a list of vectors vectors <- list(c(0.1, 0.2), c(0.4, 0.5)) calculate_geometric_mean(vectors) # example of weighted means calculate_geometric_mean(c(0.1, 10), c(0.9, 20), c(0.5, 2), weights = c(1, 2, 5))
Check which packages are installed
check_packages(...)
check_packages(...)
... |
A set of package names |
check_packages("SCORPIUS", "dynutils") check_packages(c("princurve", "mlr", "tidyverse"))
check_packages("SCORPIUS", "dynutils") check_packages(c("princurve", "mlr", "tidyverse"))
Provides common functionality for the dynverse packages. dynverse is created to support the development, execution, and benchmarking of trajectory inference methods. For more information, check out dynverse.org.
add_class()
: Add a class to an object
extend_with()
: Extend list with more data
calculate_distance()
: Calculate pairwise distances between two (sparse) matrices
calculate_similarity()
: Calculate pairwise similarities between two (sparse) matrices
calculate_mean()
: Calculate a (weighted) mean between vectors or a list of vectors; supports the arithmetic, geometric and harmonic mean
project_to_segments()
: Project a set of points to to set of segments
expand_matrix()
: Add rows and columns to a matrix
scale_uniform()
: Rescale data to have a certain center and max range
scale_minmax()
: Rescale data to a [0, 1] range
scale_quantile()
: Cut off outer quantiles and rescale to a [0, 1] range
inherit_default_params()
: Have one function inherit the default parameters from other functions
check_packages()
: Easily checking whether certain packages are installed
install_packages()
: Install packages taking into account the remotes of another
random_time_string()
: Generates a string very likely to be unique
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
safe_tempdir()
: Create an empty temporary directory and return its path
%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
recent_news()
: Print the most recent news (assumes NEWS.md file as specified by news()
)
Use calculate_distance()
instead.
euclidean_distance(x, y = NULL) correlation_distance(x, y = NULL)
euclidean_distance(x, y = NULL) correlation_distance(x, y = NULL)
x |
A numeric matrix, dense or sparse. |
y |
(Optional) a numeric matrix, dense or sparse, with |
Expand a matrix with given rownames and colnames
expand_matrix(mat, rownames = NULL, colnames = NULL, fill = 0)
expand_matrix(mat, rownames = NULL, colnames = NULL, fill = 0)
mat |
The matrix to expand |
rownames |
The desired rownames |
colnames |
The desired colnames |
fill |
With what to fill missing data |
x <- matrix(runif(12), ncol = 4, dimnames = list(c("a", "c", "d"), c("D", "F", "H", "I"))) expand_matrix(x, letters[1:5], LETTERS[1:10], fill = 0)
x <- matrix(runif(12), ncol = 4, dimnames = list(c("a", "c", "d"), c("D", "F", "H", "I"))) expand_matrix(x, letters[1:5], LETTERS[1:10], fill = 0)
Extend an object
extend_with(object, .class_name, ...)
extend_with(object, .class_name, ...)
object |
A list |
.class_name |
A class name to add |
... |
Extra information in the list |
library(purrr) l <- list(important_number = 42) %>% add_class("my_list") l %>% extend_with( .class_name = "improved_list", url = "https://github.com/dynverse/dynverse" ) l
library(purrr) l <- list(important_number = 42) %>% add_class("my_list") l %>% extend_with( .class_name = "improved_list", url = "https://github.com/dynverse/dynverse" ) l
Extracts one row from a tibble and converts it to a list
extract_row_to_list(tib, row_id)
extract_row_to_list(tib, row_id)
tib |
the tibble |
row_id |
the index of the row to be selected, or alternatively an expression which will be evaluated to such an index |
the corresponding row from the tibble as a list
list_as_tibble tibble_as_list mapdf
library(tibble) tib <- tibble( a = c(1, 2), b = list(log10, sqrt), c = c("parrot", "quest"), .object_class = list(c("myobject", "list"), c("yourobject", "list")) ) extract_row_to_list(tib, 2) extract_row_to_list(tib, which(a == 1))
library(tibble) tib <- tibble( a = c(1, 2), b = list(log10, sqrt), c = c("parrot", "quest"), .object_class = list(c("myobject", "list"), c("yourobject", "list")) ) extract_row_to_list(tib, 2) extract_row_to_list(tib, which(a == 1))
Check whether an object has certain names
has_names(x, which) x %has_names% which
has_names(x, which) x %has_names% which
x |
object to test |
which |
name |
## Not run: library(assertthat) li <- list(a = 1, b = 2) assert_that(li %has_names% "a") # TRUE assert_that(li %has_names% "c") # Error: li is missing 1 name from "c": "c" assert_that(li %has_names% letters) # Error: li is missing 24 names from letters: "c", "d", "e", ... ## End(Not run)
## Not run: library(assertthat) li <- list(a = 1, b = 2) assert_that(li %has_names% "a") # TRUE assert_that(li %has_names% "c") # Error: li is missing 1 name from "c": "c" assert_that(li %has_names% letters) # Error: li is missing 24 names from letters: "c", "d", "e", ... ## End(Not run)
Inherit default parameters from a list of super functions
inherit_default_params(super_functions, fun)
inherit_default_params(super_functions, fun)
super_functions |
A list of super functions of which 'fun“ needs to inherit the default parameters |
fun |
The function whose default parameters need to be overridden |
Function fun
, but with the default parameters of the super_functions
fun1 <- function(a = 10, b = 7) runif(a, -b, b) fun2 <- function(c = 9) 2^c fun3 <- inherit_default_params( super = list(fun1, fun2), fun = function(a, b, c) { list(x = fun1(a, b), y = fun2(c)) } ) fun3
fun1 <- function(a = 10, b = 7) runif(a, -b, b) fun2 <- function(c = 9) 2^c fun3 <- inherit_default_params( super = list(fun1, fun2), fun = function(a, b, c) { list(x = fun1(a, b), y = fun2(c)) } ) fun3
If the session is interactive, prompt the user whether to install the packages.
install_packages(..., try_install = interactive())
install_packages(..., try_install = interactive())
... |
The names of the packages to be checked |
try_install |
Whether running interactivly, which will prompt the user before installation |
## Not run: install_packages("SCORPIUS") ## End(Not run)
## Not run: install_packages("SCORPIUS") ## End(Not run)
Check whether a value within a certain interval
is_bounded( x, lower_bound = -Inf, lower_closed = FALSE, upper_bound = Inf, upper_closed = FALSE )
is_bounded( x, lower_bound = -Inf, lower_closed = FALSE, upper_bound = Inf, upper_closed = FALSE )
x |
A value to be tested |
lower_bound |
The lower bound |
lower_closed |
Whether the lower bound is closed |
upper_bound |
The upper bound |
upper_closed |
Whether the upper bound is closed |
## Not run: library(assertthat) assert_that(is_bounded(10)) # TRUE assert_that(is_bounded(10:30)) # TRUE assert_that(is_bounded(Inf)) # Error: Inf is not bounded by (-Inf,Inf) assert_that(is_bounded(10, lower_bound = 20)) # Error: 10 is not bounded by (20,Inf) assert_that(is_bounded( 10, lower_bound = 20, lower_closed = TRUE, upper_bound = 30, upper_closed = FALSE )) # Error: 10 is not bounded by [20,30) ## End(Not run)
## Not run: library(assertthat) assert_that(is_bounded(10)) # TRUE assert_that(is_bounded(10:30)) # TRUE assert_that(is_bounded(Inf)) # Error: Inf is not bounded by (-Inf,Inf) assert_that(is_bounded(10, lower_bound = 20)) # Error: 10 is not bounded by (20,Inf) assert_that(is_bounded( 10, lower_bound = 20, lower_closed = TRUE, upper_bound = 30, upper_closed = FALSE )) # Error: 10 is not bounded by [20,30) ## End(Not run)
Check whether a value is a single numeric
is_single_numeric(x)
is_single_numeric(x)
x |
A value to be tested |
## Not run: library(assertthat) assert_that(is_single_numeric(1)) # TRUE assert_that(is_single_numeric(Inf)) # TRUE assert_that(is_single_numeric(1.6)) # TRUE assert_that(is_single_numeric(NA)) # Error: NA is not a single numeric value assert_that(is_single_numeric(1:6)) # Error: 1:6 is not a single numeric value assert_that(is_single_numeric("pie")) # Error: "pie" is not a single numeric value ## End(Not run)
## Not run: library(assertthat) assert_that(is_single_numeric(1)) # TRUE assert_that(is_single_numeric(Inf)) # TRUE assert_that(is_single_numeric(1.6)) # TRUE assert_that(is_single_numeric(NA)) # Error: NA is not a single numeric value assert_that(is_single_numeric(1:6)) # Error: 1:6 is not a single numeric value assert_that(is_single_numeric("pie")) # Error: "pie" is not a single numeric value ## End(Not run)
Check if an object is a sparse matrix
is_sparse(x)
is_sparse(x)
x |
An object to test |
library(Matrix) is_sparse(matrix(1:10)) # FALSE is_sparse(Matrix::rsparsematrix(100, 200, .01)) # TRUE
library(Matrix) is_sparse(matrix(1:10)) # FALSE is_sparse(Matrix::rsparsematrix(100, 200, .01)) # TRUE
Convert a list of lists to a tibble
list_as_tibble(list_of_rows)
list_as_tibble(list_of_rows)
list_of_rows |
The list to be converted to a tibble |
A tibble with the same number of rows as there were elements in list_of_rows
tibble_as_list extract_row_to_list mapdf
library(purrr) li <- list( list(a = 1, b = log10, c = "parrot") %>% add_class("myobject"), list(a = 2, b = sqrt, c = "quest") %>% add_class("yourobject") ) tib <- list_as_tibble(li) tib
library(purrr) li <- list( list(a = 1, b = log10, c = "parrot") %>% add_class("myobject"), list(a = 2, b = sqrt, c = "quest") %>% add_class("yourobject") ) tib <- list_as_tibble(li) tib
The mapdf functions transform their input by applying a function to each row of a data frame and returning a vector the same length as the input.
These functions work a lot like purrr's map()
functions.
mapdf(.x, .f, ...) mapdf_lgl(.x, .f, ...) mapdf_chr(.x, .f, ...) mapdf_int(.x, .f, ...) mapdf_dbl(.x, .f, ...) mapdf_dfr(.x, .f, ...) mapdf_dfc(.x, .f, ...) mapdf_lat(.x, .f, ...) walkdf(.x, .f, ...)
mapdf(.x, .f, ...) mapdf_lgl(.x, .f, ...) mapdf_chr(.x, .f, ...) mapdf_int(.x, .f, ...) mapdf_dbl(.x, .f, ...) mapdf_dfr(.x, .f, ...) mapdf_dfc(.x, .f, ...) mapdf_lat(.x, .f, ...) walkdf(.x, .f, ...)
.x |
A data.frame, data_frame, or tibble. |
.f |
A function or formula.
If a function, the first argument will be the row as a list.
If a formula, e.g. |
... |
Additional arguments passed on to the mapped function. |
mapdf()
always returns a list.
mapdf_lgl()
, mapdf_int()
, mapdf_dbl()
and mapdf_chr()
return vectors of the corresponding type (or die trying).
mapdf_dfr()
and mapdf_dfc()
return data frames created by row-binding and column-binding respectively. They require dplyr to be installed.
mapdf_lat()
returns a tibble by transforming outputted lists to a tibble using list_as_tibble.
walkdf()
calls .f for its side-effect and returns the input .x.
library(dplyr) tib <- tibble( a = c(1, 2), b = list(log10, sqrt), c = c("parrot", "quest"), .object_class = list(c("myobject", "list"), c("yourobject", "list")) ) # map over the rows using a function tib %>% mapdf(class) # or use an anonymous function tib %>% mapdf(function(row) paste0(row$b(row$a), "_", row$c)) # or a formula tib %>% mapdf(~ .$b) # there are many more variations available # see ?mapdf for more info tib %>% mapdf_lgl(~ .$a > 1) tib %>% mapdf_chr(~ paste0("~", .$c, "~")) tib %>% mapdf_int(~ nchar(.$c)) tib %>% mapdf_dbl(~ .$a * 1.234)
library(dplyr) tib <- tibble( a = c(1, 2), b = list(log10, sqrt), c = c("parrot", "quest"), .object_class = list(c("myobject", "list"), c("yourobject", "list")) ) # map over the rows using a function tib %>% mapdf(class) # or use an anonymous function tib %>% mapdf(function(row) paste0(row$b(row$a), "_", row$c)) # or a formula tib %>% mapdf(~ .$b) # there are many more variations available # see ?mapdf for more info tib %>% mapdf_lgl(~ .$a > 1) tib %>% mapdf_chr(~ paste0("~", .$c, "~")) tib %>% mapdf_int(~ nchar(.$c)) tib %>% mapdf_dbl(~ .$a * 1.234)
Finds the projection index for a matrix of points x
, when
projected onto a set of segments defined by segment_start
and segment_end
.
project_to_segments(x, segment_start, segment_end)
project_to_segments(x, segment_start, segment_end)
x |
a matrix of data points. |
segment_start |
a matrix of segment start points. |
segment_end |
a matrix of segment end points. |
A list with components
x_proj |
a matrix of projections of |
segment |
the index of the segment a point is projected on |
progression |
the progression of a projection along its segment |
distance |
the distance from each point in |
x <- matrix(rnorm(50, 0, .5), ncol = 2) segfrom <- matrix(c(0, 1, 0, -1, 1, 0, -1, 0), ncol = 2, byrow = TRUE) segto <- segfrom / 10 fit <- project_to_segments(x, segfrom, segto) str(fit) # examine output
x <- matrix(rnorm(50, 0, .5), ncol = 2) segfrom <- matrix(c(0, 1, 0, -1, 1, 0, -1, 0), ncol = 2, byrow = TRUE) segto <- segfrom / 10 fit <- project_to_segments(x, segfrom, segto) str(fit) # examine output
Generate a random string with first the current time, together with a random number
random_time_string(name = NULL)
random_time_string(name = NULL)
name |
Optional string to be added in the random_time_string |
random_time_string("test")
random_time_string("test")
Read/write R objects to a H5 file.
read_h5(path) read_h5_(file_h5) write_h5(x, path) write_h5_(x, file_h5, path)
read_h5(path) read_h5_(file_h5) write_h5(x, path) write_h5_(x, file_h5, path)
path |
Path to read from/write to. |
file_h5 |
A H5 file to read from/write to. |
x |
R object to write. |
Print the most recent news
recent_news(path = NULL, package = detect_package_name(path = path), n = 2)
recent_news(path = NULL, package = detect_package_name(path = path), n = 2)
path |
The path of the description in which the package resides |
package |
The package name |
n |
Number of recent news to print |
Create an empty temporary directory and return its path
safe_tempdir(subfolder)
safe_tempdir(subfolder)
subfolder |
Name of a subfolder to be created |
## Not run: safe_tempdir("samson") # "/tmp/Rtmp8xCGJe/file339a13bec763/samson" ## End(Not run)
## Not run: safe_tempdir("samson") # "/tmp/Rtmp8xCGJe/file339a13bec763/samson" ## End(Not run)
Rescale data to a [0, 1] range
scale_minmax(x)
scale_minmax(x)
x |
A numeric vector, matrix or data frame. |
The centered, scaled matrix or vector. The numeric centering and scalings used are returned as attributes.
## Generate a matrix from a normal distribution ## with a large standard deviation, centered at c(5, 5) x <- matrix(rnorm(200*2, sd = 10, mean = 5), ncol = 2) ## Minmax scale the data x_scaled <- scale_minmax(x) ## Plot rescaled data plot(x_scaled) ## Show ranges of each column apply(x_scaled, 2, range)
## Generate a matrix from a normal distribution ## with a large standard deviation, centered at c(5, 5) x <- matrix(rnorm(200*2, sd = 10, mean = 5), ncol = 2) ## Minmax scale the data x_scaled <- scale_minmax(x) ## Plot rescaled data plot(x_scaled) ## Show ranges of each column apply(x_scaled, 2, range)
Cut off outer quantiles and rescale to a [0, 1] range
scale_quantile(x, outlier_cutoff = 0.05)
scale_quantile(x, outlier_cutoff = 0.05)
x |
A numeric vector, matrix or data frame. |
outlier_cutoff |
The quantile cutoff for outliers (default 0.05). |
The centered, scaled matrix or vector. The numeric centering and scalings used are returned as attributes.
## Generate a matrix from a normal distribution ## with a large standard deviation, centered at c(5, 5) x <- matrix(rnorm(200*2, sd = 10, mean = 5), ncol = 2) ## Scale the dataset between [0,1] x_scaled <- scale_quantile(x) ## Plot rescaled data plot(x_scaled) ## Show ranges of each column apply(x_scaled, 2, range)
## Generate a matrix from a normal distribution ## with a large standard deviation, centered at c(5, 5) x <- matrix(rnorm(200*2, sd = 10, mean = 5), ncol = 2) ## Scale the dataset between [0,1] x_scaled <- scale_quantile(x) ## Plot rescaled data plot(x_scaled) ## Show ranges of each column apply(x_scaled, 2, range)
scale_uniform
uniformily scales a given matrix such that
the returned space is centered on center
, and each column was scaled equally
such that the range of each column is at most max_range
.
scale_uniform(x, center = 0, max_range = 1)
scale_uniform(x, center = 0, max_range = 1)
x |
A numeric vector matrix or data frame. |
center |
The new center point of the data. |
max_range |
The maximum range of each column. |
The centered, scaled matrix. The numeric centering and scalings used are returned as attributes.
## Generate a matrix from a normal distribution ## with a large standard deviation, centered at c(5, 5) x <- matrix(rnorm(200*2, sd = 10, mean = 5), ncol = 2) ## Center the dataset at c(0, 0) with a minimum of c(-.5, -.5) and a maximum of c(.5, .5) x_scaled <- scale_uniform(x, center = 0, max_range = 1) ## Plot rescaled data plot(x_scaled) ## Show ranges of each column apply(x_scaled, 2, range)
## Generate a matrix from a normal distribution ## with a large standard deviation, centered at c(5, 5) x <- matrix(rnorm(200*2, sd = 10, mean = 5), ncol = 2) ## Center the dataset at c(0, 0) with a minimum of c(-.5, -.5) and a maximum of c(.5, .5) x_scaled <- scale_uniform(x, center = 0, max_range = 1) ## Plot rescaled data plot(x_scaled) ## Show ranges of each column apply(x_scaled, 2, range)
Switching of development stage within the dynverse
switch_devel(file = "DESCRIPTION", desc = desc::desc(file = file)) switch_master(file = "DESCRIPTION", desc = desc::desc(file = file)) switch_cran(file = "DESCRIPTION", desc = desc::desc(file = file))
switch_devel(file = "DESCRIPTION", desc = desc::desc(file = file)) switch_master(file = "DESCRIPTION", desc = desc::desc(file = file)) switch_cran(file = "DESCRIPTION", desc = desc::desc(file = file))
file |
The description file, defaults to DESCRIPTION |
desc |
The read in description using the desc package |
Tests whether hdf5 is correctly installed and can load/write data
test_h5_installation(detailed = FALSE) get_h5_test_data()
test_h5_installation(detailed = FALSE) get_h5_test_data()
detailed |
Whether top do a detailed check |
Convert a tibble to a list of lists
tibble_as_list(tib)
tibble_as_list(tib)
tib |
A tibble |
A list with the same number of lists as there were rows in tib
list_as_tibble extract_row_to_list mapdf
library(tibble) tib <- tibble( a = c(1, 2), b = list(log10, sqrt), c = c("parrot", "quest"), .object_class = list(c("myobject", "list"), c("yourobject", "list")) ) li <- tibble_as_list(tib) li
library(tibble) tib <- tibble( a = c(1, 2), b = list(log10, sqrt), c = c("parrot", "quest"), .object_class = list(c("myobject", "list"), c("yourobject", "list")) ) li <- tibble_as_list(tib) li