Creates or validates a subclass of a tibble. These function is mostly useful for package authors that implement subclasses of a tibble, like sf or tsibble.
new_tibble() creates a new object as a subclass of
This function is optimized for performance, checks are reduced to a minimum.
vctrs::new_data_frame() for details.
validate_tibble() checks a tibble for internal consistency.
Correct behavior can be guaranteed only if this function
runs without raising an error.
new_tibble(x, ..., nrow = NULL, class = NULL, subclass = NULL) validate_tibble(x)
A tibble-like object.
Name-value pairs of additional attributes.
The number of rows, inferred from
Subclasses to assign to the new object, default: none.
Deprecated, retained for compatibility. Please use the
x must be a list.
nrow argument may be omitted as of tibble 3.1.4.
If present, every element of the list
x should have
equal to this value.
(But this is not checked by the constructor).
This takes the place of the "row.names" attribute in a data frame.
x must have names (or be empty),
but the names are not checked for correctness.
validate_tibble() checks for "minimal" names
and that all columns are vectors, data frames or matrices.
It also makes sure that all columns have the same length,
vctrs::vec_size() is consistent with the data.
as_tibble() for ways to construct a tibble
with recycling of scalars and automatic name repair,
for lower-level implementations.
# The nrow argument is always required: new_tibble(list(a = 1:3, b = 4:6), nrow = 3) # Existing row.names attributes are ignored: try(validate_tibble(new_tibble(trees, nrow = 3))) # The length of all columns must be compatible with the nrow argument: try(validate_tibble(new_tibble(list(a = 1:3, b = 4:6), nrow = 2)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.