check_columns: Check presence of columns in dataset.

View source: R/check_columns.R

check_columnsR Documentation

Check presence of columns in dataset.

Description

Check if the input dataset (tibble or ArrowObject) df contains columns specified in col_list. col_list supports both exact matches of column names and alternative column names. In the latter case, alternative column names are elements of a character vector, and exactly one of the elements is required to be present.

Usage

check_columns(df, col_list)

Arguments

df

An Olink dataset (tibble or ArrowObject).

col_list

A list of character vectors.

Details

col_list contains a collection of character vectors. If a character vector is scalar (length = 1), the element of the vector is expected to be present among the column names of df. When an element of col_list contains more than one elements, the function will check whether the column names of df include at least one of the elements of that vector.

Value

Nothing or an error message if any column is missing.

Author(s)

Klev Diamanti Albin Lundin Lei Conze Pascal Pucholt Gil Henriques

Examples

## Not run: 
tmp_data <- dplyr::tibble(
  "A" = c(1L, 2L, 3L),
  "B" = c(TRUE, TRUE, FALSE),
  "C" = c("A", "B", "C"),
  "D" = c(FALSE, FALSE, TRUE)
)

# OK
check_columns(df = tmp_data,
              col_list = list("A", "B"))

# ERROR: E is missing
check_columns(df = tmp_data,
              col_list = list("A", "E"))

# ERROR: E and F are missing
check_columns(df = tmp_data,
              col_list = list("A", "E", "F"))

# OK
check_columns(df = tmp_data,
              col_list = list("A", c("B", "C")))

# OK
check_columns(df = tmp_data,
              col_list = list("A", c("B", "E")))

# ERROR: c(F, E) are missing
check_columns(df = tmp_data,
              col_list = list("A", c("F", "E")))

# ERROR: c(F, E) and c(M, N) are missing
check_columns(df = tmp_data,
              col_list = list("A", c("F", "E"), c("M", "N")))

## End(Not run)


OlinkAnalyze documentation built on June 24, 2026, 1:06 a.m.