View source: R/check_columns.R
| check_columns | R Documentation |
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.
check_columns(df, col_list)
df |
An Olink dataset (tibble or ArrowObject). |
col_list |
A list of character vectors. |
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.
Nothing or an error message if any column is missing.
Klev Diamanti Albin Lundin Lei Conze Pascal Pucholt Gil Henriques
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.