| check_pivot_spec | R Documentation |
speccheck_pivot_spec() is a developer facing helper function for validating
the pivot spec used in pivot_longer_spec() or pivot_wider_spec(). It is
only useful if you are extending pivot_longer() or pivot_wider() with
new S3 methods.
check_pivot_spec() makes the following assertions:
spec must be a data frame.
spec must have a character column named .name.
spec must have a character column named .value.
The .name column must be unique.
The .name and .value columns must be the first two columns in the data
frame, and will be reordered if that is not true.
check_pivot_spec(spec, call = caller_env())
spec |
A specification data frame. This is useful for more complex pivots because it gives you greater control on how metadata stored in the columns become column names in the result. Must be a data frame containing character |
# A valid spec
spec <- tibble(.name = "a", .value = "b", foo = 1)
check_pivot_spec(spec)
spec <- tibble(.name = "a")
try(check_pivot_spec(spec))
# `.name` and `.value` are forced to be the first two columns
spec <- tibble(foo = 1, .value = "b", .name = "a")
check_pivot_spec(spec)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.