1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#' @keywords internal
".someattributes<-" <- function(x, value) {
for (a in names(value)) {
attr(x, a) <- value[[a]]
}
x
}
#' @keywords internal
.nlist <- function(...) {
m <- match.call()
dots <- list(...)
no_names <- is.null(names(dots))
has_name <- if (no_names) FALSE else nzchar(names(dots))
if (all(has_name)) {
return(dots)
}
nms <- as.character(m)[-1]
if (no_names) {
names(dots) <- nms
} else {
names(dots)[!has_name] <- nms[!has_name]
}
dots
}
#' @keywords internal
#' @importFrom insight model_info
.get_model_info <- function(model, model_info = NULL, ...) {
if (is.null(model_info)) model_info <- insight::model_info(model)
model_info
}
#' @keywords internal
.safe_ranktransform <- function(x, verbose = TRUE, ...) {
if (insight::n_unique(x) == 1) {
return(rep(mean(seq_along(x)), length(x)))
}
datawizard::ranktransform(x, method = "average", ..., verbose = FALSE)
}
#' @keywords internal
.is_BF_of_type <- function(x, type, msg = type) {
if (inherits(x, "BFBayesFactor")) {
if (!inherits(x@numerator[[1]], type)) {
insight::format_error(sprintf("'x' is not a %s!", msg))
}
return(TRUE)
} else {
return(FALSE)
}
}
#' @keywords internal
.is_htest_of_type <- function(x, pattern, msg) {
if (inherits(x, "htest")) {
if (!grepl(pattern, x$method)) {
insight::format_error(sprintf("'x' is not a %s!", msg))
}
return(TRUE)
} else {
return(FALSE)
}
}
|