Skip to contents

For each row of data, returns the first non-NA, non-empty value among the supplied column names, scanning in order. Used to coalesce duplicate-named patient identifier columns (e.g. patient, patient_2).

Usage

.first_nonempty_col(data, cols)

Arguments

data

A data frame.

cols

Character vector of column names to scan in priority order. Missing columns are silently skipped.

Value

Character vector of length nrow(data). NA_character_ where no column had a non-empty value.