Package: oeli 0.7.1

Lennart Oelschläger

oeli: Utilities for Developing Data Science Software

Some general helper functions that I (and maybe others) find useful when developing data science software.

Authors:Lennart Oelschläger [aut, cre]

oeli_0.7.1.tar.gz
oeli_0.7.1.tar.gz(r-4.5-noble)oeli_0.7.1.tar.gz(r-4.4-noble)
oeli_0.7.1.tgz(r-4.4-emscripten)oeli_0.7.1.tgz(r-4.3-emscripten)
oeli.pdf |oeli.html
oeli/json (API)
NEWS

# Install 'oeli' in R:
install.packages('oeli', repos = 'https://cloud.r-project.org')

Bug tracker:https://github.com/loelschlaeger/oeli/issues1 issues

Pkgdown site:https://loelschlaeger.de

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3

On CRAN:

Conda:

openblascpp

3.48 score 4 packages 447 downloads 85 exports 90 dependencies

Last updated 4 months agofrom:142eb61148. Checks:2 OK. Indexed: no.

TargetResultLatest binary
Doc / VignettesOKMar 27 2025
R-4.5-linux-x86_64OKMar 27 2025

Exports:assert_correlation_matrixassert_covariance_matrixassert_list_of_listsassert_numeric_vectorassert_probability_vectorassert_transition_probability_matrixcheck_correlation_matrixcheck_covariance_matrixcheck_list_of_listscheck_numeric_vectorcheck_probability_vectorcheck_transition_probability_matrixchol_to_covchunk_vectorcorrelated_regressorscov_to_cholddirichletddirichlet_cppdelete_columns_data.framedeltaDictionarydiff_covdmvnormdmvnorm_cppdo.call_timeddtnormdtnorm_cppdttnormdttnorm_cppdwishartdwishart_cppfunction_argumentsfunction_bodyfunction_defaultsgroup_data.frameidentical_structureinput_check_responseinsert_matrix_columninsert_vector_entryMmap_indicesmatch_argmatch_numericsmatrix_diagonal_indicesmatrix_indicesmerge_listspackage_logopermutationsprint_data.frameprint_matrixquietrdirichletrdirichlet_cpprmvnormrmvnorm_cppround_data.framertnormrtnorm_cpprttnormrttnorm_cpprwishartrwishart_cppsample_correlation_matrixsample_covariance_matrixsample_transition_probability_matrixsimulate_markov_chainsplit_vector_atstationary_distributionStoragesubsetssystem_informationtest_correlation_matrixtest_covariance_matrixtest_list_of_liststest_numeric_vectortest_probability_vectortest_transition_probability_matrixtimedtry_silentundiff_covunexpected_errorunique_choluser_confirmvariable_namevector_occurrence

Dependencies:askpassassertthatbackportsBBbenchmarkmebenchmarkmeDatabriocallrcheckmateclicodetoolscolorspacecrayoncurldescdiffobjdigestdoParalleldplyrevaluatefansifarverforeachfsgenericsGenOrdggfunggimageggplot2ggplotifyglueGPArotationgridGraphicsgtablehexbinhexStickerhttrisobanditeratorsjsonlitelabelinglatex2explatticelifecyclemagickmagrittrMASSMatrixmgcvmimemnormtmunsellmvtnormnleqslvnlmeopensslpillarpkgbuildpkgconfigpkgloadpraiseprocessxpspsychquadprogR6RColorBrewerRcppRcppArmadillorlangrprojrootscalesshowtextshowtextdbSimMultiCorrDatastringistringrsyssysfontstestthattibbletidyselecttriangleutf8vctrsVGAMviridisLitewaldowithryulab.utils

Citation

To cite package ‘oeli’ in publications use:

Oelschläger L (2024). oeli: Utilities for Developing Data Science Software. R package version 0.7.1, https://CRAN.R-project.org/package=oeli.

Corresponding BibTeX entry:

  @Manual{,
    title = {oeli: Utilities for Developing Data Science Software},
    author = {Lennart Oelschläger},
    year = {2024},
    note = {R package version 0.7.1},
    url = {https://CRAN.R-project.org/package=oeli},
  }

Readme and manuals

Utilities for developing R software

The {oeli} package offers a collection of handy functions that I found useful while developing R packages. Perhaps you’ll find them helpful too!

Installation

The released package version can be installed from CRAN via:

install.packages("oeli")

Demos

The package includes helpers for various tasks and objects. Some demos are shown below. Click the headings for reference pages with documentation on all available helpers in each category.

DistributionsDistributions

The package has density and sampling functions for distributions not in base R, such as Dirichlet, multivariate normal, truncated normal, and Wishart.

ddirichlet(x = c(0.2, 0.3, 0.5), concentration = 1:3)
#> [1] 4.5
rdirichlet(concentration = 1:3)
#> [1] 0.1273171 0.5269401 0.3457428

For faster computation, Rcpp implementations are also available:

microbenchmark::microbenchmark(
  "R"    = rmvnorm(mean = c(0, 0, 0), Sigma = diag(3)),
  "Rcpp" = rmvnorm_cpp(mean = c(0, 0, 0), Sigma = diag(3))
)
#> Unit: microseconds
#>  expr   min     lq    mean median     uq    max neval
#>     R 200.5 208.25 263.396 217.10 234.35 2154.7   100
#>  Rcpp   2.7   2.90   5.386   4.05   4.40   72.0   100
Function helpersFunction helpers

Retrieving default arguments of a function:

f <- function(a, b = 1, c = "", ...) { }
function_defaults(f)
#> $b
#> [1] 1
#> 
#> $c
#> [1] ""
Indexing helpersIndexing helpers

Create all possible permutations of vector elements:

permutations(LETTERS[1:3])
#> [[1]]
#> [1] "A" "B" "C"
#> 
#> [[2]]
#> [1] "A" "C" "B"
#> 
#> [[3]]
#> [1] "B" "A" "C"
#> 
#> [[4]]
#> [1] "B" "C" "A"
#> 
#> [[5]]
#> [1] "C" "A" "B"
#> 
#> [[6]]
#> [1] "C" "B" "A"
Package helpersPackage helpers

Quickly have a basic logo for your new package:

package_logo("my_package", brackets = TRUE, use_logo = FALSE)

How to print a matrix without filling up the entire console?

x <- matrix(rnorm(10000), ncol = 100, nrow = 100)
print_matrix(x, rowdots = 4, coldots = 4, digits = 2, label = "what a big matrix")
#> what a big matrix : 100 x 100 matrix of doubles 
#>         [,1]  [,2]  [,3] ... [,100]
#> [1,]    2.39   0.3 -0.48 ...   0.56
#> [2,]   -1.33  0.62  0.37 ...  -1.21
#> [3,]   -0.03 -0.43  1.71 ...   0.07
#> ...      ...   ...   ... ...    ...
#> [100,]  0.14 -0.16  2.49 ...  -1.58

And what about a data.frame?

x <- data.frame(x = rnorm(1000), y = LETTERS[1:10])
print_data.frame(x, rows = 7, digits = 0)
#>      x  y
#> 1     0 A
#> 2    -1 B
#> 3     0 C
#> 4    -1 D
#> < 993 rows hidden >
#>          
#> 998  -1 H
#> 999  -1 I
#> 1000  0 J
Simulation helpersSimulation helpers

Let’s simulate a Markov chain:

Gamma <- sample_transition_probability_matrix(dim = 3)
simulate_markov_chain(Gamma = Gamma, T = 20)
#>  [1] 2 1 1 3 1 1 2 2 3 2 2 2 2 2 1 1 1 1 1 3
Transformation helpersTransformation helpers

The group_data.frame() function groups a given data.frame based on the values in a specified column:

df <- data.frame("label" = c("A", "B"), "number" = 1:10)
group_data.frame(df = df, by = "label")
#> $A
#>   label number
#> 1     A      1
#> 3     A      3
#> 5     A      5
#> 7     A      7
#> 9     A      9
#> 
#> $B
#>    label number
#> 2      B      2
#> 4      B      4
#> 6      B      6
#> 8      B      8
#> 10     B     10
Validation helpersValidation helpers

Is my matrix a proper transition probability matrix?

matrix <- diag(4)
matrix[1, 2] <- 1
check_transition_probability_matrix(matrix)
#> [1] "Must have row sums equal to 1"

Help Manual

Help pageTopics
Check correlation matrixassert_correlation_matrix check_correlation_matrix test_correlation_matrix
Check covariance matrixassert_covariance_matrix check_covariance_matrix test_covariance_matrix
Check list of listsassert_list_of_lists check_list_of_lists test_list_of_lists
Check numeric vectorassert_numeric_vector check_numeric_vector test_numeric_vector
Check probability vectorassert_probability_vector check_probability_vector test_probability_vector
Check transition probability matrixassert_transition_probability_matrix check_transition_probability_matrix test_transition_probability_matrix
Split a vector into chunkschunk_vector
Simulate correlated regressor valuescorrelated_regressors
Cholesky root of covariance matrixchol_to_cov cov_to_chol unique_chol
Dirichlet distributionddirichlet ddirichlet_cpp rdirichlet rdirichlet_cpp
Deleting 'data.frame' columnsdelete_columns_data.frame
Dictionary R6 ObjectDictionary
Difference and un-difference covariance matrixdelta diff_cov M undiff_cov
Multivariate normal distributiondmvnorm dmvnorm_cpp rmvnorm rmvnorm_cpp
Measure computation timedo.call_timed
Truncated normal distributiondtnorm dtnorm_cpp dttnorm dttnorm_cpp rtnorm rtnorm_cpp rttnorm rttnorm_cpp
Wishart distributiondwishart dwishart_cpp rwishart rwishart_cpp
Get function argumentsfunction_arguments
Extract function bodyfunction_body
Get default function argumentsfunction_defaults
Grouping of a 'data.frame'group_data.frame
Check if two objects have identical structureidentical_structure
Standardized response to input checkinput_check_response
Insert column in matrixinsert_matrix_column
Insert entry in vectorinsert_vector_entry
Map indicesmap_indices
Argument matchingmatch_arg
Best-possible match of two numeric vectorsmatch_numerics
Get indices of matrix diagonalmatrix_diagonal_indices
Get 'matrix' indicesmatrix_indices
Merge named listsmerge_lists
Creating a basic logo for an R packagepackage_logo
Build permutationspermutations
Print (abbreviated) 'data.frame'print_data.frame
Print (abbreviated) 'matrix'print_matrix
Silence R codequiet
Round 'numeric' columns of a 'data.frame'round_data.frame
Sample correlation matrixsample_correlation_matrix
Sample covariance matrixsample_covariance_matrix
Sample transition probability matricessample_transition_probability_matrix
Simulate Markov chainsimulate_markov_chain
Split a vector at positionssplit_vector_at
Stationary distributionstationary_distribution
Storage R6 ObjectStorage
Generate vector subsetssubsets
General system level informationsystem_information
Interrupt long evaluationstimed
Try an expression silentlytry_silent
Handling of an unexpected errorunexpected_error
User confirmationuser_confirm
Determine variable namevariable_name
Find the positions of first or last occurrence of unique vector elementsvector_occurrence