fp_extract_labeltext: Extract label text columns

View source: R/fp_extract_labeltext.R

fp_extract_labeltextR Documentation

Extract label text columns

Description

Build a labeltext data frame from selected columns. This helper supports both tidyselect syntax and explicit character column names.

Usage

fp_extract_labeltext(x, ..., cols = NULL, names = NULL, na = "")

Arguments

x

A data frame (grouped or ungrouped).

...

Columns selected using tidyselect syntax.

cols

Optional explicit character vector of column names. Cannot be combined with ....

names

Optional replacement names for the extracted columns.

na

Replacement value for missing values in atomic scalar cells.

Details

For grouped data frames, extraction follows the grouped forestplot row alignment logic so that label rows correspond to the first grouped estimate panel.

Value

A data frame suitable for labeltext in forestplot().

Examples

data(inventors_vs_mello)

# ungrouped selection with explicit columns
fp_extract_labeltext(
    inventors_vs_mello,
    cols = c("author", "ai", "n1i", "ci", "n2i", "orci"),
    names = c("Study", "E1", "N1", "E2", "N2", "OR"),
    na = ""
)

# grouped extraction follows grouped forestplot row alignment
# (rename estimate columns to mean/lower/upper for grouped extraction)
inventors_vs_mello |>
    dplyr::rename(mean = est, lower = lb, upper = ub) |>
    dplyr::group_by(group) |>
    fp_extract_labeltext(author, orci, na = "")

forestplot documentation built on March 4, 2026, 9:06 a.m.