util_expect_data_frame: Verify, that argument is a data frame

View source: R/util_expect_data_frame.R

util_expect_data_frameR Documentation

Verify, that argument is a data frame

Description

stops with an error, if not. will add the columns, and return the resulting extended data frame, and also updating the original data frame in the calling environment, if #' x is empty (data frames easily break to 0-columns in R, if they have not rows, e.g. using some split/rbind pattern)

Usage

util_expect_data_frame(x, col_names, convert_if_possible, dont_assign)

Arguments

x

an object that is verified to be a data.frame.

col_names

column names x must contain or named list of predicates to check the columns (e.g., list(AGE=is.numeric, SEX=is.character))

convert_if_possible

if given, for each column, a lambda can be given similar to col_names check functions. This lambda would be used to try a conversion. If a conversion fails (returns NA, where the input was not ‘util_empty’), an error is still thrown, the data is converted, otherwise

dont_assign

set TRUE to keep x in the caller environment untouched

Value

invisible data frame


dataquieR documentation built on July 26, 2023, 6:10 p.m.