xb_help: Error-Checked Row and Column Binding of 1+ of Compatible Data...

View source: R/xb.R

xb_helpR Documentation

Error-Checked Row and Column Binding of 1+ of Compatible Data Frames or 1+ Compatible Matrices

Description

Error-checked extensions of rbind and/or cbind that can handle NULL arguments as long as there is at least one non-NULL ... argument.

Usage

xb_help()

cb(...)

rb(...)

Arguments

...

Multiple compatible atomic matrices or multiple compatible atomic data.frames.

Value

An atomic data.frame or an atomic matrix.

Functions

  • cb(): Columns binds any compatible non-NULL ... arguments. If there is only one nonNULL argument and it is a matrix or data.frame, returns that argument.

  • rb(): Row binds any compatible non-NULL ... arguments. If there is only one nonNULL argument and it is a matrix or data.frame, returns that argument.

Examples

egXb <- function() {
  m2x2  <- base::matrix(1:4, nrow = 2)
  m3x2  <- base::matrix(1:6, nrow = 3)
  m3x3  <- base::matrix(1:9, nrow = 3)
  m4x4  <- base::matrix(1:16, nrow = 4)
  d4x2  <- tibble::tibble(w = 1:4, x = letters[1:4])
  d4x4  <- tibble::tibble(w = 1:4, x = letters[1:4], y = NA, z = '.')
  d2x4  <- tibble::tibble(w = 1:2, x = letters[1:2], y = NA, z = '.')
  d4x4b <- tibble::tibble(W = 1:4, X = letters[1:4], Y = NA, Z = '.')

  list(m2x2  = uj::cb(m2x2, NULL, NULL),
       m2x4  = uj::cb(m2x2, m2x2, NULL),
       m2x6  = uj::cb(m2x2, m2x2, m2x2),
       m3x2  = uj::rb(m3x2, NULL, NULL),
       m5x2  = uj::rb(m3x2, m2x2, NULL),
       m7x2  = uj::rb(m3x2, m2x2, m2x2),
       m12x7 = uj::cb(uj::rb(m4x4, m4x4, m4x4), uj::rb(m3x3, m3x3, m3x3, m3x3)),
       d4x2  = uj::cb(d4x2, NULL , NULL),
       d4x6  = uj::cb(d4x2, d4x4b, NULL),
       d4x8  = uj::cb(d4x4, d4x4b, NULL),
       d6x4  = uj::rb(d2x4, d4x4 , NULL),
       d8x4  = uj::rb(d2x4, d4x4 , d2x4))
}
egXb <- egXb()

j-martineau/uj documentation built on Sept. 14, 2024, 4:40 a.m.