Skip to contents
  • gt_signif() colours cells: numeric unadjusted p-values below alpha (light green), numeric adjusted p-values below alpha (medium green, bold), and text cells "effect; p = ..." (light green when p < alpha, medium green bold when the cell ends with *).

  • gt_highlight_rows() colours whole rows (selected columns), e.g. robust associations (dark green, white bold text).

  • gt_signif_legend() adds a legend of the colours under the table.

Use after any theme function: the cell styles are added on top of it.

Usage

gt_signif(
  x,
  p_cols = NULL,
  fdr_cols = NULL,
  text_cols = NULL,
  alpha = 0.05,
  colors = gt_sig_colors(),
  legend = TRUE
)

gt_highlight_rows(
  x,
  rows,
  columns = NULL,
  level = c("robust", "fdr", "nominal"),
  colors = gt_sig_colors()
)

gt_signif_legend(
  x,
  colors = gt_sig_colors(),
  alpha = 0.05,
  robust = TRUE,
  fdr = TRUE
)

Arguments

x

A gt_tbl.

p_cols

Numeric columns of unadjusted p-values.

fdr_cols

Numeric columns of adjusted p-values.

text_cols

Text columns containing "p = ...".

alpha

Significance level.

colors

Named colours nominal, fdr, robust (see gt_sig_colors()).

legend

Add the colour legend.

rows

Logical vector or indices of the rows to highlight.

columns

Columns to colour (default: the first two).

level

"robust", "fdr" or "nominal".

robust, fdr

Show these entries in the legend.

Value

A gt_tbl.

Examples

cm <- cor_matrix_test(cohort_sim, c(NFL_V0, IL6_V0, CRP_V0, MOCA_V0))
gt_pub(cm$long) |>
  gt_signif(p_cols = "p", fdr_cols = "p_adj") |>
  gt_highlight_rows(cm$long$p_adj < 0.01, columns = c("Var1", "Var2"))
Var1 Var2 r p n p_adj
NFL_V0 IL6_V0 0.06 0.48 120 0.6
NFL_V0 CRP_V0 -0.06 0.54 115 0.6
IL6_V0 CRP_V0 0.05 0.6 115 0.6
NFL_V0 MOCA_V0 -0.55 7.0×10⁻¹¹ 120 4.2×10⁻¹⁰
IL6_V0 MOCA_V0 -0.05 0.6 120 0.6
CRP_V0 MOCA_V0 -0.07 0.43 115 0.6
p < 0.05significant after FDR (< 0.05)