imed_check_comparability: Check scientific comparability of an analysis subset

View source: R/filter_guard.R

imed_check_comparabilityR Documentation

Check scientific comparability of an analysis subset

Description

Check scientific comparability of an analysis subset

Usage

imed_check_comparability(
  x,
  action = c("error", "warn", "return"),
  require_single_unit = TRUE
)

Arguments

x

An 'imed_db', or a measurement-level data frame that includes comparability metadata (for example from 'imed_filter()').

action

error, warn, or return.

require_single_unit

Require one reported unit. Convertible units should first be explicitly standardized outside this function.

Value

A 'tibble' with columns 'comparable' (logical) and 'issue' (character; '"None"' when no problem is found) if 'action = "return"'. For 'action = "error"' or '"warn"' the function returns invisibly a single logical value ('TRUE' if the records are comparable) and stops or warns when they are not.

Examples

toy <- data.frame(
  Study_ID = paste0("S", 1:12),
  Comparability_Class = "CLASS_A",
  Reported_Unit = "items/L",
  Metric_Type = "Abundance",
  Strict_Synthesis_Eligibility = "YES",
  Group = rep(c("g1", "g2"), 6),
  Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2),
  SD = rep(c(0.6, 0.9), 6),
  N = rep(c(10, 12, 8), 4)
)
imed_check_comparability(toy, action = "return")

imedR documentation built on Nov. 3, 2026, 5:08 p.m.