Skip to content

Commit

Permalink
standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
ddsjoberg committed Jan 31, 2024
1 parent badcf73 commit 9866a08
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
21 changes: 12 additions & 9 deletions R/standalone-checks.R → R/import-standalone-checks.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# Standalone file: do not edit by hand
# Source: <https://github.com/ddsjoberg/standalone/blob/main/R/standalone-checks.R>
# ----------------------------------------------------------------------
#
# DO NOT MODIFY THIS FILE. INSTEAD MODIFY THE VERSION IN https://github.com/ddsjoberg/standalone/tree/main/R
# ---
# repo: ddsjoberg/standalone
# file: standalone-checks.R
# last-updated: 2024-01-24
# license: https://unlicense.org
# imports: rlang, cli
# imports: [rlang, cli]
# ---
#
# This file provides a minimal shim to provide a purrr-like API on top of
# base R functions. They are not drop-in replacements but allow a similar style
# of programming.
# This file provides a minimal functions to check argument values and types
# passed by users to functions in packages.
#
# ## Changelog
# nocov start

# styler: off

#' Check Class
#'
Expand Down Expand Up @@ -111,7 +114,7 @@ check_scalar <- function(x, arg_name = rlang::caller_arg(x), call = parent.frame
check_range <- function(x,
range,
include_bounds = c(FALSE, FALSE),
arg_name = caller_arg(x),
arg_name = rlang::caller_arg(x),
scalar = FALSE,
msg = paste(
"The {.arg {arg_name}} argument must be in the interval",
Expand Down Expand Up @@ -166,8 +169,8 @@ check_range <- function(x,
#' @return invisible
#' @keywords internal
#' @noRd
check_binary <- function(x, arg_name = caller_arg(x), call = parent.frame()) {
if (!is.logical(x) && !(is_integerish(x) && is_empty(setdiff(x, c(0, 1, NA))))) {
check_binary <- function(x, arg_name = rlang::caller_arg(x), call = parent.frame()) {
if (!is.logical(x) && !(rlang::is_integerish(x) && rlang::is_empty(setdiff(x, c(0, 1, NA))))) {
paste(
"Expecting column {.arg {arg_name}} to be either {.cls logical}",
"or {.cls {c('numeric', 'integer')}} coded as {.val {c(0, 1)}}."
Expand All @@ -178,5 +181,5 @@ check_binary <- function(x, arg_name = caller_arg(x), call = parent.frame()) {
invisible()
}


# nocov end
# styler: on
6 changes: 6 additions & 0 deletions R/standalone-forcats.R → R/import-standalone-forcats.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Standalone file: do not edit by hand
# Source: <https://github.com/ddsjoberg/standalone/blob/main/R/standalone-forcats.R>
# ----------------------------------------------------------------------
#
# DO NOT MODIFY THIS FILE. INSTEAD MODIFY THE VERSION IN https://github.com/ddsjoberg/standalone/tree/main/R
# ---
# file: standalone-forcats.R
Expand All @@ -13,6 +17,7 @@
# ## Changelog
#
# nocov start
# styler: off

fct_infreq <- function(f, ordered = NA) {
# reorder by frequency
Expand All @@ -32,3 +37,4 @@ fct_inorder <- function(f, ordered = NA) {
}

# nocov end
# styler: on
4 changes: 4 additions & 0 deletions R/standalone-purrr.R → R/import-standalone-purrr.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Standalone file: do not edit by hand
# Source: <https://github.com/r-lib/rlang/blob/main/R/standalone-purrr.R>
# ----------------------------------------------------------------------
#
# ---
# repo: r-lib/rlang
# file: standalone-purrr.R
Expand Down
11 changes: 11 additions & 0 deletions R/standalone-stringr.R → R/import-standalone-stringr.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Standalone file: do not edit by hand
# Source: <https://github.com/ddsjoberg/standalone/blob/main/R/standalone-stringr.R>
# ----------------------------------------------------------------------
#
# DO NOT MODIFY THIS FILE. INSTEAD MODIFY THE VERSION IN https://github.com/ddsjoberg/standalone/tree/main/R
# ---
# file: standalone-stringr.R
Expand All @@ -13,6 +17,7 @@
# ## Changelog
#
# nocov start
# styler: off

str_trim <- function(string, side = c("both", "left", "right")) {
side <- rlang::arg_match(side)
Expand All @@ -39,3 +44,9 @@ str_extract <- function(string, pattern) {
str_detect <- function(string, pattern) {
grepl(pattern = pattern, x = string)
}

# nocov end
# styler: on



0 comments on commit 9866a08

Please sign in to comment.