Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
vertesy committed Jan 7, 2024
1 parent 34e886f commit 7f11fbd
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export("%!in%")
export(AddTrailingDotIfNonePresent)
export(AddTrailingSlashfNonePresent)
export(FixPath)
Expand Down Expand Up @@ -46,6 +47,7 @@ export(pps)
export(ppu)
export(sppp)
export(spps)
export(stopif)
export(substrRight)
export(toCamelCase)
export(toDotSeparated)
Expand Down
41 changes: 41 additions & 0 deletions R/Stringendo.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,47 @@
# try(source("https://raw.githubusercontent.com/vertesy/Stringendo/main/Stringendo.R"), silent = T)



# ______________________________________________________________________________________________----
# Control functions ----
# _________________________________________________________________________________________________

# ______________________________________________________________________________________________________________________________
#' @title Stop Execution If Condition is True
#'
#' @description This function stops the execution of the script if the provided condition evaluates to TRUE.
#' It is the complement of the `stopifnot()` function and is used for asserting conditions where
#' an error should be thrown if the condition is TRUE, rather than FALSE.
#' @param condition A logical condition to be tested. If TRUE, an error message is thrown and execution is stopped.
#' @param message An optional error message to display if the condition is TRUE.
#'
#' @examples a <- 1
#' stopif(a != 1, message = "A is 1")
#' @export
stopif <- function(condition, message = 'Condition is TRUE.') {
if (isTRUE(condition)) stop(message)
}


# ______________________________________________________________________________________________________________________________
#' @title Negation of '%in%' Operator
#'
#' @description
#' `%!in%` is used to test if elements of one vector are not present in another vector.
#' It is the negation of the `%in%` operator. This operator returns `TRUE` for elements
#' of `x` that are not in `y`.
#'
#' @param x A vector of values to be matched.
#' @param y A vector of values to be matched against.
#' @return A logical vector indicating if elements in `x` are not present in `y`.
#' @examples
#' c(1, 2, 3) %!in% c(2, 4, 6)
#' # [1] TRUE FALSE TRUE
#' @export
'%!in%' <- function(x, y) !('%in%'(x, y))



# ______________________________________________________________________________________________----
# Generic auxiliary functions ----
# _________________________________________________________________________________________________
Expand Down
25 changes: 25 additions & 0 deletions man/grapes-not-in-grapes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/stopif.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7f11fbd

Please sign in to comment.