zlog_df: Calculate z/zlog Values for a data.frame

View source: R/zlog_df.R

z_dfR Documentation

Calculate z/zlog Values for a data.frame

Description

Calculates the z or z(log) values for laboratory measurement standardisation as proposed in Hoffmann 2017 et al. for a complete data.frame.

Usage

z_df(x, limits, probs = c(0.025, 0.975), log = FALSE)

zlog_df(x, limits, probs = c(0.025, 0.975))

Arguments

x

data.frame, with the columns: "age", numeric, "sex", factor and more user defined numeric columns that should be z/z(log) transformed.

limits

data.frame, reference table, has to have the columns: "age", numeric (same units as in age, e.g. days or years, age of 0 matches all ages), "sex", factor (same levels for male and female as sex and a special level "both"), "param", character with the laboratory parameter name that have to match the column name in x, "lower" and "upper", numeric for the lower and upper reference limits.

probs

numeric, probabilities of the lower and upper reference limit, default: c(0.025, 0.975) (spanning 95 %). Has to be of length 2 for numeric or a two-column matrix with as many rows as elements in x.

log

logical, should z (log = FALSE, default) or z(log) (log = TRUE) calculated?

Details

This is a wrapper function for z() and lookup_limits(). Please find the details for the z/z(log) calculation at z().

zlog_df is an alias for z_df(..., log = TRUE).

Value

data.frame, with the columns: "age", "sex" and all numeric columns z/zlog transformed. If a column name is missing in limits$param a warning is thrown and the column is set to NA.

Author(s)

Sebastian Gibb

References

Georg Hoffmann, Frank Klawonn, Ralf Lichtinghagen, and Matthias Orth. 2017. "The Zlog-Value as Basis for the Standardization of Laboratory Results." LaboratoriumsMedizin 41 (1): 23–32. doi: 10.1515/labmed-2016-0087.

See Also

zlog()

Examples

l <- data.frame(
    param = c("alb", "bili"),
    age = c(0, 0),
    sex = c("both", "both"),
    units = c("mg/l", "µmol/l"),
    lower = c(35, 2),
    upper = c(52, 21)
)
x <- data.frame(
    age = 40:48,
    sex = rep(c("female", "male"), c(5, 4)),
    # from Hoffmann et al. 2017
    alb = c(42, 34, 38, 43, 50, 42, 27, 31, 24),
    bili = c(11, 9, 2, 5, 22, 42, 37, 200, 20)
)
z_df(x, l)

zlog_df(x, l)

zlog documentation built on Jan. 6, 2023, 1:25 a.m.