introduce | R Documentation |
Works like dplyr::mutate()
but without changing existing columns, but only
adding new ones. Useful to add possibly missing columns with default values.
introduce(.data, ...)
.data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details. |
... |
< The value can be:
|
# ensure columns "y" and "z" exist
tibble::tibble(x=1:3) %>%
introduce(y="a", z=paste0(y, dplyr::row_number()))
# ensure columns "y" and "z" exist, but do not overwrite "y"
tibble::tibble(x=1:3, y=c("c", "d", "e")) %>%
introduce(y="a", z=paste0(y, dplyr::row_number()))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.