Demo_Manuscript/zz_equivalence_helpers.R

eq_single <- function(z, d) {
  PAutilities::paired_equivalence_test(
    d[ ,z[1]], d[ ,z[2]], "comparison",
    scale = "relative", relative_region_width = 0.10
  ) %>%
  .[["results"]] %>%
  data.frame(
    x = z[1], y = z[2], .,
    stringsAsFactors = FALSE,
    row.names = NULL
  )
}

eq_wrapper <- function(d) {
  names(d) %>%
  .[grepl("kcal", .)] %>%
  combn(2, simplify = FALSE) %>%
  lapply(eq_single, d = d) %>%
  do.call(rbind, .)
}
PAHPLabResearch/FLASH documentation built on May 15, 2020, 7:08 p.m.