Detect metric columns in a data frame, dataset-agnostically
Source:R/16_report_helpers.R
dot-detect_metric_columns.RdReturns the names of numeric columns in data that can sensibly
be summarized as quantitative metrics in per-theme + per-subtheme
tables. Package-internal columns (those pakhom engineers itself –
sentiment_score, emotion_intensity, theme_membership_*, etc.) are
excluded; everything else numeric is a candidate.
Details
Explicit override path: when config$data$column_mappings$metric_columns
is non-empty, those names are used verbatim (intersected with the data's
columns to avoid referencing missing fields). This matches the explicit
detect_columns() mapping path in R/07_data_loading.R.
Mirrors (and consolidates) the metric-column detection used by
prepare_correlation_data (R/14_correlations.R).
Caveat – sentiment_score collision
The auto-detect path excludes sentiment_score (the package-
engineered column from R/10_sentiment.R) by name. If a user's
corpus happens to have its own sentiment_score numeric
column that they want treated AS A METRIC, the auto-detect silently
drops it. Workaround: supply an explicit override via
config$data$column_mappings$metric_columns (or the direct
explicit= arg) – the override path returns the requested
columns verbatim, bypassing the internal-column exclusion. The
same collision applies to any other internal name
(emotion_intensity, n_themes, etc.).