Add roxygen2 documentation for custom infix operators
This commit is contained in:
parent
186fce48da
commit
0aae59491e
1 changed files with 24 additions and 0 deletions
|
|
@ -1,15 +1,39 @@
|
|||
# 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) {
|
||||
!(a %in% b)
|
||||
}
|
||||
|
||||
# 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) {
|
||||
!(all(a %in% b))
|
||||
}
|
||||
|
||||
# infix for null replacement
|
||||
#' @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) {
|
||||
a %||% b
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue