Add roxygen2 documentation for custom infix operators

This commit is contained in:
gnoblet 2025-07-02 13:45:17 +02:00
parent 186fce48da
commit 0aae59491e

View file

@ -1,15 +1,39 @@
# not in # not in
#' Not In Operator
#'
#' A negation of the `%in%` operator that tests if elements of `a` are not in `b`.
#'
#' @param a Vector or value to test
#' @param b Vector to test against
#'
#' @return Logical vector with TRUE for elements of `a` that are not in `b`
`%notin%` <- function(a, b) { `%notin%` <- function(a, b) {
!(a %in% b) !(a %in% b)
} }
# not all in # not all in
#' Not All In Operator
#'
#' Tests if not all elements of `a` are contained in `b`.
#'
#' @param a Vector to test
#' @param b Vector to test against
#'
#' @return TRUE if at least one element of `a` is not in `b`, otherwise FALSE
`%notallin%` <- function(a, b) { `%notallin%` <- function(a, b) {
!(all(a %in% b)) !(all(a %in% b))
} }
# infix for null replacement # infix for null replacement
#' @importFrom rlang `%||%` #' @importFrom rlang `%||%`
#' If Null Replace Operator
#'
#' An alias for the `%||%` operator that returns `a` if it's not NULL, otherwise returns `b`.
#'
#' @param a First value to test
#' @param b Value to use if `a` is NULL
#'
#' @return `a` if not NULL, otherwise `b`
`%ifnullrep%` <- function(a, b) { `%ifnullrep%` <- function(a, b) {
a %||% b a %||% b
} }