Skip to content

Commit

Permalink
chore: add file missing from previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kolomanski committed Nov 5, 2024
1 parent b8d8e45 commit b06371f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#' Evaluates range notation. If provided notation is invalid, returns NA. In example,
#' eval_range("1:5") returns c(1,2,3,4,5).
#' TODO: provide proper documentation.
#'
#' @param x character string with range notation, eg. 1:5.
#' @returns numeric vector with specified range of numbers, NA if notation is invalid
#' @export
.eval_range <- function(x) {
val_range <- try(eval(parse(text = paste0("c(", x, ")"))), silent = TRUE)
if (inherits(val_range, "try-error")) NA else val_range
}

0 comments on commit b06371f

Please sign in to comment.