Description Usage Arguments Details Value Examples
exact_cols
returns the exact column names, including the case.
1 | exact_cols(tbl, cols)
|
tbl |
A tibble or dataframe. |
cols |
A character vector of column names. |
This particularly useful when working with Microsoft SQL Server tables as the column names may be case sensitive. This is also useful when working with table metadata and the exact column names are required for matching purposes.
tbl_vars does not return case sensitive columns, thus the the need for this function.
A character vector of column names with the appropriate case.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## create tibble
my_tibble <- tibble::tribble(
~MixedCase, ~lowercase, ~UPPERCASE, ~aLtCaSe,
1, 11, 111, 1111,
2, 22, 222, 2222,
3, 33, 333, 3333
)
## column names to search for, ignoring case
my_cols <- c("mixedcase", "altcase")
my_cols_case <- my_tibble %>%
exact_cols(my_cols)
## particularly useful when combined with dplyr::one_of
my_tibble %>%
dplyr::select(dplyr::one_of(my_cols_case))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.