R/zzz.R

Defines functions release_questions access_data is_centered is_contrast

# Checks if the input can be considered as a contrast-coded vector.
# Args:
#   x: a numeric vector
# Returns:
#   A boolean.
is_contrast <- function(x) {
  length(unique(x)) == 2L & sum(unique(x)) == 0
}

# Checks if the input can be considered as a centered vector.
# Args:
#   x: a numeric vector
# Returns:
#   A boolean.
is_centered <- function(x) {
  # implementation to deal with floating number rounding error
  isTRUE(all.equal(mean(x), 0))
}


access_data <- function(mediation_model, variable) {
  variable_q <- enquo(variable)

  purrr::pluck(mediation_model, "data") %>%
    dplyr::pull(!! variable_q)
}

release_questions <- function() {
  c(
    "Have run `urlchecker::url_check()`?"
    )
}

Try the JSmediation package in your browser

Any scripts or data that you put into this service are public.

JSmediation documentation built on Feb. 16, 2023, 7:25 p.m.