View source: R/annotating-mutate.R
| mutate_annotation | R Documentation | 
Usually, metadata should be a reflection of what the data
should represent and act as a check on the generation code.
However, in the course of data aggregation, it can be common to
perform massive transformations that would be cumbersome to
document manually. This exposes a metadata-manipulation framework
prior to metadata file creation, in the style of tidytable::mutate.
mutate_annotation(.data, .field, ..., .overwrite = TRUE)
mutate_annotation_across(
  .data,
  .field,
  .fn,
  .cols = tidyselect::everything(),
  .with_names = FALSE,
  ...,
  .overwrite = TRUE
)
| .data | A  | 
| .field | The name of the annotation field that you wish to modify | 
| ... | For  For  | 
| .overwrite | If  | 
| .fn | A function that takes in a vector and arbitrary arguments  | 
| .cols | A tidyselect-compatible selection of variables to be edited | 
| .with_names | If  | 
A data.frame with annotated columns
# Adds a "mean" annotation to 'mpg'
mutate_annotation(mtcars, "mean", mpg = mean(mpg))
# Adds a "mean" annotation to all variables in `mtcars`
mutate_annotation_across(mtcars, "mean", .fn = mean)
# Adds a "title" annotation that copies the column name
mutate_annotation_across(
  mtcars,
  "title",
  .fn = function(x, nx) nx,
  .with_names = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.