THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

61 lines
1.7 KiB

## From R.utils 2.0.2 (2015-05-23)
hpaste <- function(..., sep = "", collapse = ", ", last_collapse = NULL,
max_head = if (missing(last_collapse)) 3 else Inf,
max_tail = if (is.finite(max_head)) 1 else Inf,
abbreviate = "...") {
max_head <- as.double(max_head)
max_tail <- as.double(max_tail)
if (is.null(last_collapse)) last_collapse <- collapse
# Build vector 'x'
x <- paste(..., sep = sep)
n <- length(x)
# Nothing todo?
if (n == 0) return(x)
if (is.null(collapse)) return(x)
# Abbreviate?
if (n > max_head + max_tail + 1) {
head <- x[seq_len(max_head)]
tail <- rev(rev(x)[seq_len(max_tail)])
x <- c(head, abbreviate, tail)
n <- length(x)
}
if (!is.null(collapse) && n > 1) {
if (last_collapse == collapse) {
x <- paste(x, collapse = collapse)
} else {
x_head <- paste(x[1:(n - 1)], collapse = collapse)
x <- paste(x_head, x[n], sep = last_collapse)
}
}
x
}
stopf <- function(fmt, ..., call. = TRUE, domain = NULL) { #nolint
stop(sprintf(fmt, ...), call. = call., domain = domain)
}
warnf <- function(fmt, ..., call. = TRUE, domain = NULL) { #nolint
warning(sprintf(fmt, ...), call. = call., domain = domain)
}
stop_if_not <- function(...) {
res <- list(...)
n <- length(res)
if (n == 0L) return()
for (ii in 1L:n) {
res_ii <- .subset2(res, ii)
if (length(res_ii) != 1L || is.na(res_ii) || !res_ii) {
mc <- match.call()
call <- deparse(mc[[ii + 1]], width.cutoff = 60L)
if (length(call) > 1L) call <- paste(call[1L], "...")
stop(sQuote(call), " is not TRUE", call. = FALSE, domain = NA)
}
}
}