Skip to contents

labtable is used to plot a table that summarises laboratory values with continuous outcomes for baseline and each post-baseline timepoint by treatment arms using the following summary statistics:

  • Mean (SD)

  • Median (IQR)

  • Number of missing

  • Treatment effect estimate (Intervention vs Control, 95% CI)

Usage

labtable(
  data,
  control,
  intervention_levels,
  lab_test = "lab_test",
  visit = "visit",
  id = "id",
  arm = "arm",
  aval = "aval",
  treatment_effect_estimate = TRUE,
  model_formula = "aval ~ arm + (1|id)",
  mean = TRUE,
  median = TRUE,
  n_missing = TRUE,
  control_name = NULL,
  intervention_names = NULL,
  IQR_format = c("iqr", "percentile"),
  mean_dp = 1,
  SD_dp = 1,
  median_dp = 1,
  IQR_dp = 1,
  estimate_sf = 3,
  CI_sf = 3,
  save_image_path = NULL,
  save_docx_path = NULL
)

Arguments

data

dataframe with lab_test, visit, id, arm and aval columns (optional: variables to be included in the model)

control

factor level of control arm

intervention_levels

vector of factor levels for interventions

lab_test

name of lab_test column

visit

name of visit column

id

name of id column

arm

name of arm column

aval

name of aval column

treatment_effect_estimate

a logical value whether to include treatment effect estimate and 95% CI column

model_formula

formula for linear mixed model to estimate treatment effect and 95% CI

mean

a logical value whether to include mean and SD row in summary table

median

a logical value whether to include median and IQR row in summary table

n_missing

a logical value whether to include number of missing n row in summary table

control_name

name of control arm

intervention_names

vector of names for interventions

IQR_format

format of IQR: to be presented as single "iqr" value or as 25th and 75th "percentile"

mean_dp

number of decimal places for mean

SD_dp

number of decimal places for standard deviation

median_dp

number of decimal places for median

IQR_dp

number of decimal places for IQR

estimate_sf

number of significant figures for treatment effect estimate

CI_sf

number of significant figures for 95% CI

save_image_path

file path to save table as image

save_docx_path

file path to save table as docx

Value

flextable of laboratory values summary for baseline and each post-baseline timepoint by treatment arms

Treatment Effect Estimate

The treatment effect and its 95% confidence interval is estimated via a linear mixed model with laboratory measurement as response. The formula of the model can be specified through the model_formula argument. The default model is aval ~ arm + (1|id).

Examples

labtable(lab2, control="Placebo", intervention_levels=c("Intervention"))

Lab Measure

Intervention (N₁=67)

Placebo (N₂=68)

Treatment effect estimate
(Intervention vs Control, 95% CI)

Lymphocytes (GI/L)

Week 0

Mean (SD)

2 (1.1)

2 (0.9)

0.0598 (-0.193, 0.313)

Median (IQR)

1.8 (1.1)

1.9 (1.1)

Number of missing

0

3

Week 4

Mean (SD)

2 (0.9)

1.9 (0.7)

Median (IQR)

1.7 (1.1)

1.8 (0.9)

Number of missing

4

4

Week 8

Mean (SD)

2 (1)

1.9 (0.7)

Median (IQR)

1.9 (1.1)

1.7 (0.8)

Number of missing

2

3

Week 12

Mean (SD)

2 (1)

1.8 (0.7)

Median (IQR)

1.8 (0.8)

1.8 (0.8)

Number of missing

1

5

Week 16

Mean (SD)

2 (0.9)

2 (0.8)

Median (IQR)

1.7 (0.9)

1.9 (1.1)

Number of missing

3

4

Week 20

Mean (SD)

1.9 (0.8)

2 (0.7)

Median (IQR)

1.7 (1.1)

1.9 (0.8)

Number of missing

1

6

Week 24

Mean (SD)

2 (0.8)

1.9 (0.6)

Median (IQR)

1.8 (1.1)

1.8 (1)

Number of missing

3

5

Monocytes (GI/L)

Week 0

Mean (SD)

0.5 (0.2)

0.5 (0.2)

0.00342 (-0.0532, 0.0601)

Median (IQR)

0.4 (0.3)

0.4 (0.2)

Number of missing

0

3

Week 4

Mean (SD)

0.5 (0.2)

0.4 (0.2)

Median (IQR)

0.5 (0.2)

0.4 (0.2)

Number of missing

4

4

Week 8

Mean (SD)

0.5 (0.2)

0.5 (0.2)

Median (IQR)

0.4 (0.2)

0.5 (0.2)

Number of missing

2

3

Week 12

Mean (SD)

0.5 (0.2)

0.5 (0.2)

Median (IQR)

0.4 (0.3)

0.4 (0.3)

Number of missing

1

5

Week 16

Mean (SD)

0.5 (0.2)

0.5 (0.2)

Median (IQR)

0.5 (0.3)

0.5 (0.3)

Number of missing

3

4

Week 20

Mean (SD)

0.5 (0.2)

0.5 (0.2)

Median (IQR)

0.5 (0.3)

0.5 (0.3)

Number of missing

1

6

Week 24

Mean (SD)

0.5 (0.2)

0.5 (0.2)

Median (IQR)

0.4 (0.2)

0.4 (0.3)

Number of missing

3

5

Potassium (mmol/L)

Week 0

Mean (SD)

4.2 (0.3)

4.2 (0.3)

-0.031 (-0.119, 0.0572)

Median (IQR)

4.2 (0.4)

4.2 (0.3)

Number of missing

0

1

Week 4

Mean (SD)

4.2 (0.3)

4.2 (0.3)

Median (IQR)

4.1 (0.5)

4.2 (0.3)

Number of missing

4

1

Week 8

Mean (SD)

4.2 (0.3)

4.3 (0.3)

Median (IQR)

4.2 (0.4)

4.1 (0.4)

Number of missing

1

3

Week 12

Mean (SD)

4.2 (0.3)

4.2 (0.3)

Median (IQR)

4.2 (0.4)

4.2 (0.4)

Number of missing

3

5

Week 16

Mean (SD)

3.9 (NA)

NA (NA)

Median (IQR)

3.9 (0)

NA (NA)

Number of missing

66

68

Week 20

Mean (SD)

4.2 (0.3)

4.2 (0.3)

Median (IQR)

4.2 (0.5)

4.2 (0.4)

Number of missing

1

6

Week 24

Mean (SD)

4.2 (0.3)

4.2 (0.3)

Median (IQR)

4.2 (0.4)

4.2 (0.4)

Number of missing

2

7