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)
util_expect_data_frame(x, col_names, convert_if_possible, dont_assign)invisible data frame
an object that is verified to be a data.frame.
column names x must contain or named list of predicates to check the columns (e.g., list(AGE=is.numeric, SEX=is.character))
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
set TRUE to keep x in the caller environment untouched