View source: R/utils-dataframe.R
if_col_present | R Documentation |
The simple use case. For more complex behaviour see switch_pipeline()
.
if_col_present(df, col, if_present, if_missing = ~.x)
df |
a dataframe |
col |
a column name |
if_present |
a |
if_missing |
a |
either the value of if_present
/if_absent
or the result of calling
if_present
/if_absent
as functions on df
.
iris %>% if_col_present(Species, ~ .x %>% dplyr::rename(new = Species)) %>%
colnames()
# in contrast to `purrr` absolute values are not interpreted as function names
iris %>% if_col_present(Species2, "Yes", "No")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.