compatible: Are objects compatible?

View source: R/compatible.R

compatibleR Documentation

Are objects compatible?

Description

  compatible Evaluates whether all ... arguments are compatible, meaning all numeric, all character, all logical, all unordered factor with the same levels, or ordered factor with the same levels in the same order.
   
  compatible_xy Evaluates whether all X and Y are compatible.
   
  compatible_mats   Evaluates whether all ... arguments are compatible matrices and (for row binding) have the same number of columns or (for column binding) have the same number of rows.
   
  compatible_dtfs Evaluates whether all ... arguments are atomic data.frames. For row binding, also evaluates whether they have the same number of columns and all corresponding columns are compatible. For column binding, also evaluates whether they have the same number of rows.

Usage

compatible(..., .rec = FALSE)

compatible_xy(x, y, .rec = FALSE)

compatible_mats(dim, ...)

compatible_dtfs(dim, ...)

Arguments

...

An arbitrary number of arguments to be checked for compatibility with each other.

.rec

TRUE or FALSE indicating whether arguments in ... must be recyclable to be compatible.

dim

Integer scalar indicating type of binding to check for compatibility (1 = row, 2 = col).

Value

A logical scalar.

See Also

Other properties: as_mmm(), bbb_ccc_help(), bbb_help(), bbb_mmm_prop_funs(), ccc_help(), cls(), cmp_ccc_help(), cmp_mmm_ccc_help(), cmp_mmm_help(), ddd_prop_funs(), eee_help(), iii_help(), meets(), mmm_ccc_help(), mmm_help(), ppp_fast_help(), ppp_help(), sss_ccc_help(), sss_prop_funs(), unq_ccc_prop_funs(), unq_mmm_ccc_help(), unq_mmm_help()

Examples

egn0 <- 0
egN7 <- 0:7
egN9 <- 0:9
egL0 <- egn0 < 4
egL7 <- egN7 < 3
egL9 <- egN9 < 2
egC0 <- as.character(egn0)
egC7 <- as.character(egN7)
egC9 <- as.character(egN9)
u00 <- factor(egC0, levels = egC0, ordered = F)
u07 <- factor(egC0, levels = egC7, ordered = F)
u09 <- factor(egC0, levels = egC9, ordered = F)
u79 <- factor(egC7, levels = egC9, ordered = F)
u99 <- factor(egC9, levels = egC9, ordered = F)
o00 <- factor(egC0, levels = egC0, ordered = F)
o07 <- factor(egC0, levels = egC7, ordered = F)
o09 <- factor(egC0, levels = egC9, ordered = F)
o79 <- factor(egC7, levels = egC9, ordered = F)
o99 <- factor(egC9, levels = egC9, ordered = F)
egDTFncl7 <- data.frame(N = egN7, C = egC7, L = egL7)
egDTFncl9 <- data.frame(N = egN9, C = egC9, L = egL9)
egDTFcln7 <- data.frame(C = egC7, L = egL7, N = egN7)
egDTFcln9 <- data.frame(C = egC9, L = egL9, N = egN9)
compatible(egn0, egN7, egN9)
compatible(egC0, egC7, egC9, .rec = T)
compatible(egC0, egC7, egC9)
compatible(egL0, egL7, egL9, .rec = T)
compatible(egL0, egL7, egL9)
compatible(egn0, egN7, egN9, .rec = T)
compatible(u09, u79, u99)
compatible(u00, u07, u09)
compatible(o09, o79, o99)
compatible(o00, o07, o09)
compatible_dtfs("r", dtfNCL7, dtfNCL9)
compatible_dtfs("c", dtfNCL7, dtfNCL9)
compatible_dtfs("r", dtfNCL7, dtfCLN7)
compatible_dtfs("c", dtfNCL7, dtfCLN7)

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