Detect if df has col
has_col(df, col)
df
A dataframe.
col
A string or string vector.
colnames(mtcars) has_col(mtcars, c("mpg", "cyl")) has_col(mtcars, c("mpg", "foo"))