validate_columns: Validate columns for a data.frame

Description Usage Arguments Value Author(s) Examples

View source: R/validate_columns.R

Description

This function looks at the different possible column names given and chooses the one present in a data.frame. If none of the column names fit or if multiple names fit the function stops with an appropriate error message. The functions returns a list with the column names existing that can be used.

Usage

1
validate_columns(data, columns, verbose = FALSE)

Arguments

data

data.frame to check for columns.

columns

List of column names to be checked if they exist.

verbose

Logical if message should be printed. Default = FALSE

Value

Returns list of columns that are present

Author(s)

Peter Blattmann

Examples

1
2
3
4
5
6
7
8
{
 validate_columns(cars, list(Speed = c("speed")))
 
 # if out of two possible column one exists
 validate_columns(cars, list(Speed = c("speed", "velocity")))
 validate_columns(cars, list(Speed = c("speed", "velocity")), verbose = TRUE)
 
 }

SWATH2stats documentation built on April 17, 2021, 6:01 p.m.