| Title: | Rectangle Nested Lists |
| Version: | 0.4.0 |
| Description: | A tool to rectangle a nested list, that is to convert it into a 'tibble'. This is done automatically or according to a given specification. A common use case is for nested lists coming from parsing 'JSON' files, or the 'JSON' responses of 'REST' 'APIs'. 'Rectangling' uses the 'vctrs' package, and therefore offers a wide support of vector types. |
| License: | MIT + file LICENSE |
| URL: | https://tibblify.wrangle.zone, https://github.com/wranglezone/tibblify |
| BugReports: | https://github.com/wranglezone/tibblify/issues |
| Depends: | R (≥ 4.1.0) |
| Imports: | cli (≥ 3.6.2), glue, lifecycle, purrr (≥ 1.0.2), rlang (≥ 1.2.0), tibble (≥ 3.2.1), tidyselect (≥ 1.2.0), vctrs (≥ 0.7.2), withr (≥ 2.5.2) |
| Suggests: | covr (≥ 3.6.1), jsonlite (≥ 1.8.0), knitr (≥ 1.40), memoise (≥ 2.0.1), repurrrsive, rmarkdown (≥ 2.16), spelling (≥ 2.2), stbl, testthat (≥ 3.1.4), tidyr, yaml (≥ 2.3.6) |
| LinkingTo: | vctrs |
| VignetteBuilder: | knitr |
| Config/roxygen2/version: | 8.0.0 |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| LazyData: | true |
| NeedsCompilation: | yes |
| Packaged: | 2026-05-08 18:00:43 UTC; jonth |
| Author: | Jon Harmon |
| Maintainer: | Jon Harmon <jonthegeek@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-05-09 16:30:02 UTC |
tibblify: Rectangle Nested Lists
Description
A tool to rectangle a nested list, that is to convert it into a 'tibble'. This is done automatically or according to a given specification. A common use case is for nested lists coming from parsing 'JSON' files, or the 'JSON' responses of 'REST' 'APIs'. 'Rectangling' uses the 'vctrs' package, and therefore offers a wide support of vector types.
Author(s)
Maintainer: Jon Harmon jonthegeek@gmail.com (ORCID)
Authors:
Jon Harmon jonthegeek@gmail.com (ORCID)
Maximilian Girlich maximilian.girlich@outlook.com [copyright holder]
Other contributors:
Kirill Müller [contributor]
See Also
Useful links:
Report bugs at https://github.com/wranglezone/tibblify/issues
Abort when x is neither an object nor a list of objects
Description
Abort when x is neither an object nor a list of objects
Usage
.abort_not_tibblifiable(x, arg = caller_arg(x), call = caller_env())
Arguments
x |
( |
arg |
( |
call |
( |
Value
Nothing. Called for its side effect of throwing an error.
Accumulate ancestor chains for a single snapshot level
Description
Accumulate ancestor chains for a single snapshot level
Usage
.accumulate_snapshot_level(cur_ancestors, snapshot, id_col, call)
Arguments
cur_ancestors |
( |
snapshot |
( |
id_col |
( |
call |
( |
Value
A list of ancestor vectors for the next level, where each vector is the ancestor vector of the parent row with the parent id appended.
Apply nesting at a single tree level
Description
Apply nesting at a single tree level
Usage
.apply_nest_lvl(x_split, cur_lvl, children, parent_col, id_col, children_to)
Arguments
x_split |
( |
cur_lvl |
( |
children |
( |
parent_col |
( |
id_col |
( |
children_to |
( |
Value
A data frame of parents with their children nested into a column.
Apply nesting across all tree levels
Description
Apply nesting across all tree levels
Usage
.apply_nesting(
x,
id_col,
parent_col,
children_to,
id_col_name,
call = caller_env()
)
Arguments
x |
( |
id_col |
( |
parent_col |
( |
children_to |
( |
id_col_name |
( |
call |
( |
Value
A nested data frame with root elements at the top level.
Apply required flags to a list of tib fields
Description
Apply required flags to a list of tib fields
Usage
.apply_required(fields, required)
Arguments
fields |
( |
required |
( |
Value
(list) The same fields list with required = TRUE set on the
named fields.
Rename list elements back to their original spec keys
Description
Reverses tibblify's field renaming by mapping column names back to the
original keys defined in spec.
Usage
.apply_spec_renaming(x, spec, call = caller_env())
Arguments
x |
( |
spec |
( |
call |
( |
Value
A named list with elements keyed by the original spec keys.
Assemble the ancestors column for unnest_tree() output
Description
Assemble the ancestors column for unnest_tree() output
Usage
.assemble_ancestors_col(out, ancestors_to, tree_levels, call)
Arguments
out |
( |
ancestors_to |
( |
tree_levels |
( |
call |
( |
Value
A vector of ancestor ids with the same length as nrow(out).
Assemble the level column for unnest_tree() output
Description
Assemble the level column for unnest_tree() output
Usage
.assemble_level_col(out, level_to, level_data, call)
Arguments
out |
( |
level_data |
( |
call |
( |
Value
An integer vector of levels with the same length as nrow(out).
Assemble the parent id column for unnest_tree() output
Description
Assemble the parent id column for unnest_tree() output
Usage
.assemble_parent_col(out, parent_to, tree_levels, id_col, call)
Arguments
out |
( |
parent_to |
( |
tree_levels |
( |
id_col |
( |
call |
( |
Value
A vector of parent ids with the same type as out[[id_col]] and
the same length as nrow(out).
Assemble the final output from per-level data
Description
Assemble the final output from per-level data
Usage
.assemble_tree_output(
tree_levels,
id_col,
level_to,
parent_to,
ancestors_to,
call = caller_env()
)
Arguments
tree_levels |
( |
id_col |
( |
level_to |
( |
parent_to |
( |
ancestors_to |
( |
call |
( |
Value
(data.frame) The assembled output with metadata columns appended.
Backtick-wrap a character vector
Description
Backtick-wrap a character vector
Usage
.backtick(x)
Arguments
x |
( |
Value
A character vector with each element wrapped in backticks and any existing backticks escaped with a backslash.
Build ancestor chains across levels using accumulate
Description
Build ancestor chains across levels using accumulate
Usage
.build_level_ancestors(snapshots, id_col, call)
Arguments
snapshots |
( |
id_col |
( |
call |
( |
Value
A list of length length(snapshots), where element k is a list
of ancestor vectors (one per row at level k).
Convert POSIXlt to POSIXct
Description
Convert POSIXlt to POSIXct
Usage
.cast_posixlt_ptype(x)
Arguments
x |
( |
Value
An object of class POSIXct if the input is POSIXlt (to be in
line with https://github.com/r-lib/vctrs/issues/1576), otherwise the
input unchanged.
Validate that arguments are different
Description
Validate that arguments are different
Usage
.check_arg_different(arg, ..., arg_name = caller_arg(arg), call = caller_env())
Arguments
arg |
( |
... |
Other arguments that |
arg_name |
( |
call |
( |
Value
arg (invisibly). Throws an error if any values are identical.
Confirm that children_to is usable
Description
Confirm that children_to is usable
Usage
.check_children_to(children_to, id_col, parent_col, call = caller_env())
Arguments
children_to |
( |
id_col |
( |
parent_col |
( |
call |
( |
Value
The input children_to object as a string.
Check that a column name does not already exist in a data frame
Description
Check that a column name does not already exist in a data frame
Usage
.check_col_new(
x,
col_name,
col_arg = caller_arg(col_name),
x_arg = "x",
call = caller_env()
)
Arguments
x |
( |
col_name |
( |
col_arg |
( |
x_arg |
( |
call |
( |
Value
x (invisibly). Throws an error if col_name is already a column
of x.
Check that a column has no duplicate values
Description
Check that a column has no duplicate values
Usage
.check_col_value_duplicates(x, x_arg, call = caller_env())
Arguments
x |
( |
x_arg |
( |
call |
( |
Value
The input x.
Check that a column has no missing values
Description
Check that a column has no missing values
Usage
.check_col_values_missing(x, x_arg, call = caller_env())
Arguments
x |
( |
x_arg |
( |
call |
( |
Value
The input x.
Check that id column has no missing or duplicate values
Description
Check that id column has no missing or duplicate values
Usage
.check_id(x, x_arg, call = caller_env())
Arguments
x |
( |
x_arg |
( |
call |
( |
Value
The input x.
Check that id column has no missing or duplicate values
Description
Check that id column has no missing or duplicate values
Usage
.check_id_col(id_col, x, call = caller_env())
Arguments
id_col |
( |
x |
( |
call |
( |
Value
The integer index of the id column.
Confirm that an object is a data frame
Description
Confirm that an object is a data frame
Usage
.check_is_df(x, x_arg = caller_arg(x), call = caller_env())
Arguments
x |
( |
x_arg |
( |
call |
( |
Value
The input object.
Check if a key is valid
Description
Check if a key is valid
Usage
.check_key(.key, .call = caller_env())
Arguments
.key |
( |
.call |
( |
Value
(NULL) Throws an error if invalid.
Check that a key is valid for untibblify
Description
Validates that key is a length-1 character string by chaining
.check_key_length_1() and .check_key_is_character().
Usage
.check_key_can_untibblify(key, call = caller_env())
Arguments
key |
( |
call |
( |
Value
key if valid; otherwise throws an error.
Check that a key is a character string
Description
Check that a key is a character string
Usage
.check_key_is_character(key, call = caller_env())
Arguments
key |
( |
call |
( |
Value
key if valid; otherwise throws an error.
Check that a key has length 1
Description
Check that a key has length 1
Usage
.check_key_length_1(key, call = caller_env())
Arguments
key |
( |
call |
( |
Value
key if valid; otherwise throws an error.
Validate that an input is a list
Description
Validate that an input is a list
Usage
.check_list(
x,
...,
allow_null = FALSE,
arg = caller_arg(x),
call = caller_env()
)
Arguments
x |
( |
... |
Additional arguments passed to |
allow_null |
( |
arg |
( |
call |
( |
Value
NULL (invisibly) if valid; otherwise throws an error.
Check that all elements have assigned tree levels
Description
Check that all elements have assigned tree levels
Usage
.check_lvls(lvls, call = caller_env())
Arguments
lvls |
( |
call |
( |
Value
The input lvls.
Abort for missing names
Description
Abort for missing names
Usage
.check_named(x, call)
Arguments
x |
( |
call |
( |
Value
NULL (invisibly).
Abort for duplicate names
Description
Abort for duplicate names
Usage
.check_names_not_duplicated(x, call)
Arguments
x |
( |
call |
( |
Value
NULL (invisibly).
Check that .names_to is valid for the given input form
Description
Check that .names_to is valid for the given input form
Usage
.check_names_to(.names_to, .input_form, .call = caller_env())
Arguments
.names_to |
( |
.input_form |
(
|
.call |
( |
Value
NULL (invisibly).
Abort if x is a data frame
Description
Abort if x is a data frame
Usage
.check_not_df(x, call)
Arguments
x |
( |
call |
( |
Value
x (invisibly).
Abort if x is not a list of objects
Description
Abort if x is not a list of objects
Usage
.check_object_list(x, arg = caller_arg(x), call = caller_env())
Arguments
x |
( |
arg |
( |
call |
( |
Value
x (invisibly). Called for side effect.
Abort for missing or duplicate names
Description
Abort for missing or duplicate names
Usage
.check_object_names(x, call)
Arguments
x |
( |
call |
( |
Value
NULL (invisibly).
Ensure the OpenAPI version is supported
Description
Ensure the OpenAPI version is supported
Usage
.check_openapi_version(openapi_spec)
Arguments
openapi_spec |
( |
Value
The input openapi_spec if the version is supported.
Check that parent column is valid and distinct from id column
Description
Check that parent column is valid and distinct from id column
Usage
.check_parent_col(parent_col, x, id_col, id_col_name, call = caller_env())
Arguments
parent_col |
( |
x |
( |
id_col |
( |
id_col_name |
( |
call |
( |
Value
The integer index of the parent column.
Check that parent ids aren't missing
Description
Check that parent ids aren't missing
Usage
.check_parent_id_missing(parent_ids, ids, call = caller_env())
Arguments
parent_ids |
( |
ids |
( |
call |
( |
Value
The input parent_ids.
Confirm that parent ids are usable
Description
Confirm that parent ids are usable
Usage
.check_parent_ids(x, parent_col, id_col, id_col_name, call = caller_env())
Arguments
x |
( |
parent_col |
( |
id_col |
( |
id_col_name |
( |
call |
( |
Value
The parent ids, cast to the same type as ids.
Check and determine whether to print names for tibblifying
Description
Check and determine whether to print names for tibblifying
Usage
.check_print_names_arg(names)
Arguments
names |
( |
Value
A logical value indicating whether to print names for tibblifying,
based on the provided names argument or the tibblify.print_names option
if names is NULL.
Check that no element is its own parent
Description
Check that no element is its own parent
Usage
.check_self_reference(parent_ids, ids, call = caller_env())
Arguments
parent_ids |
( |
ids |
( |
call |
( |
Value
The input parent_ids.
Check dots arguments for tspec combine
Description
Check dots arguments for tspec combine
Usage
.check_tspec_combine_dots(..., .call = caller_env())
Arguments
... |
Specifications to combine. |
.call |
( |
Value
(list) A list of specifications.
Check spec types for compatibility
Description
Check spec types for compatibility
Usage
.check_tspec_combine_type(spec_list, .call = caller_env())
Arguments
spec_list |
( |
.call |
( |
Value
(character(1)) The type of the specifications.
Validate an output column name and check it differs from prior names
Description
Validate an output column name and check it differs from prior names
Usage
.check_unnest_col_diff(
col_name,
x,
...,
col_arg = caller_arg(col_name),
call = caller_env()
)
Arguments
col_name |
( |
x |
( |
... |
Already-reserved column names that |
col_arg |
( |
call |
( |
Value
col_name or NULL.
Validate and normalize an output column name
Description
Validate and normalize an output column name
Usage
.check_unnest_col_name(
col_name,
x,
col_arg = caller_arg(col_name),
call = caller_env()
)
Arguments
col_name |
( |
x |
( |
col_arg |
( |
call |
( |
Value
col_name (cast to character) or NULL.
Choose native ptype class
Description
Choose native ptype class
Usage
.choose_native_ptype(.ptype, .class, .fields)
Arguments
.ptype |
( |
.class |
( |
.fields |
( |
Value
(character or NULL) The native ptype class name.
Guess whether a field is required across a list of data frames
Description
Guess whether a field is required across a list of data frames
Usage
.col_guess_required(col_name, df_list)
Arguments
col_name |
( |
df_list |
( |
Value
(logical(1)) TRUE if col_name is present in every data frame,
FALSE otherwise.
Convert a column to a tib field specification
Description
Convert a column to a tib field specification
Usage
.col_to_spec(col, name, empty_list_unspecified, local_env)
Arguments
col |
( |
name |
( |
empty_list_unspecified |
( |
local_env |
( |
Value
A tib field specification.
Convert a df-typed list column to a tib_df specification
Description
Delegates to .list_of_col_to_spec_df() or .non_list_of_col_to_spec_df()
based on whether col is a list_of() column.
Usage
.col_to_spec_df(
ptype,
col,
name,
list_of_col,
empty_list_unspecified,
local_env
)
Arguments
ptype |
( |
col |
( |
name |
( |
list_of_col |
( |
empty_list_unspecified |
( |
local_env |
( |
Value
A tib_df() specification.
Collapse expressions with padding and optional multi-line formatting
Description
Collapse expressions with padding and optional multi-line formatting
Usage
.collapse_with_pad(x, multi_line, nchar_prefix = 0, width)
Arguments
x |
( |
multi_line |
( |
nchar_prefix |
( |
width |
( |
Value
A single string with the expressions collapsed, either on a single line or wrapped across multiple lines with indentation.
Collect formatted field parts
Description
Collect formatted field parts
Usage
.collect_parts(fields, width, force_names, args)
Arguments
fields |
( |
width |
( |
force_names |
( |
args |
( |
Value
A character vector of formatted field parts.
Traverse the tree and collect per-level data
Description
Traverse the tree and collect per-level data
Usage
.collect_tree_levels(
x,
id_col,
child_col,
parent_to,
ancestors_to,
call = caller_env()
)
Arguments
x |
( |
id_col |
( |
child_col |
( |
parent_to |
( |
ancestors_to |
( |
call |
( |
Value
A named list with elements level_data, out_ptype, level_sizes,
level_parent_ids, and level_ancestors.
Combine processed simple and complex fields
Description
Combine processed simple and complex fields
Usage
.combine_processed_fields(
spec_simple,
spec_complex,
coll_locations,
is_sub,
first_keys
)
Arguments
spec_simple |
( |
spec_complex |
( |
coll_locations |
( |
is_sub |
( |
first_keys |
( |
Value
A list with fields, locations, and keys.
Map to a character vector
Description
Map to a character vector
Usage
.compat_map_chr(x, .f, ...)
Arguments
x |
( |
.f |
( |
... |
Additional arguments passed to |
Value
(character) The mapped character vector.
Format a data frame column reference for error messages
Description
Format a data frame column reference for error messages
Usage
.data_field_name(col_name)
Value
A string in the form "x$col".
Handle deprecated arguments
Description
Handle deprecated arguments
Usage
.deprecate_arg(
good_arg,
bad_arg,
fn_name = rlang::call_name(rlang::caller_call()),
pkg_version = "0.4.0",
good_arg_name = rlang::caller_arg(good_arg),
bad_arg_name = rlang::caller_arg(bad_arg),
.call = rlang::caller_env(),
user_env = rlang::caller_env(2)
)
Arguments
good_arg |
( |
bad_arg |
( |
fn_name |
( |
pkg_version |
( |
good_arg_name |
( |
bad_arg_name |
( |
.call |
( |
user_env |
( |
Value
(any) The value to use.
Convert a nested data frame column to a tib_row specification
Description
Convert a nested data frame column to a tib_row specification
Usage
.df_col_to_spec(col, name, empty_list_unspecified, local_env)
Arguments
col |
( |
name |
( |
empty_list_unspecified |
( |
local_env |
( |
Value
A tib_row() specification.
Guess whether each field is required in a df-typed list column
Description
Guess whether each field is required in a df-typed list column
Usage
.df_guess_required(fields_spec, col, ptype)
Arguments
fields_spec |
( |
col |
( |
ptype |
( |
Value
fields_spec with $required updated for each field.
Wrap a string in double quotes if it's not NULL
Description
Wrap a string in double quotes if it's not NULL
Usage
.double_quote(x)
Arguments
x |
( |
Value
The input string wrapped in double quotes if it was not NULL, or
NULL.
Remove empty lists from an object
Description
Remove empty lists from an object
Usage
.drop_empty_lists(x)
Arguments
x |
( |
Value
The input object with empty lists removed. If any were removed, the
returned object has an attribute had_empty_lists set to TRUE.
Convert a path element to a subset string
Description
Convert a path element to a subset string
Usage
.element_subset_string(elt)
Arguments
elt |
( |
Value
A string representing a subset operation for the given path element,
such as "$a" or "[[1]]".
Evaluate and extract a single column selection
Description
Evaluate and extract a single column selection
Usage
.eval_pull(x, col, col_arg, call = caller_env())
Arguments
x |
( |
col |
( |
col_arg |
( |
call |
( |
Value
An integer index of the selected column, named by the column name.
Extract and validate the children list from a level data frame
Description
Extract and validate the children list from a level data frame
Usage
.extract_children(x, child_col, call = caller_env())
Arguments
x |
( |
child_col |
( |
call |
( |
Value
(list) The children list extracted from x[[child_col]].
Create a minimal tibble from a list
Description
Create a minimal tibble from a list
Usage
.fast_tibble(x, n = NULL)
Arguments
x |
( |
n |
( |
Value
(tbl_df) A tibble constructed directly from x.
Extract tib fields from schema properties
Description
Extract tib fields from schema properties
Usage
.fields_from_schema_properties(schema, openapi_spec)
Arguments
schema |
( |
openapi_spec |
( |
Value
A named list of tib field specs corresponding to the schema properties, with required flags applied.
Finalize a tibblify object
Description
Finalize a tibblify object
Usage
.finalize_tspec_object(field_spec, field)
## S3 method for class 'tib_collector'
.finalize_tspec_object(field_spec, field)
## S3 method for class 'tib_scalar'
.finalize_tspec_object(field_spec, field)
## S3 method for class 'tib_row'
.finalize_tspec_object(field_spec, field)
Arguments
field_spec |
( |
field |
( |
Value
The finalized field spec.
Flatten nested field specifications
Description
Flatten nested field specifications
Usage
.flatten_fields(.fields)
Arguments
.fields |
( |
Value
A flattened, named list of field specifications.
Forget memoised version of .parse_schema
Description
Forget memoised version of .parse_schema
Usage
.forget_parse_schema_memoised()
Value
If memoise is installed, TRUE if the function is memoised, FALSE
otherwise. If memoise is not installed, NULL (invisibly).
Format field parts with canonical names
Description
Format field parts with canonical names
Usage
.format_field_canonical_names(fields, width, force_names)
Arguments
fields |
( |
width |
( |
force_names |
( |
Value
A character vector of formatted field parts with canonical names potentially suppressed.
Format fields to print a function call
Description
Format fields to print a function call
Usage
.format_fields(f_name, fields, width, force_names, args = NULL)
Arguments
f_name |
( |
fields |
( |
width |
( |
force_names |
( |
args |
( |
Value
A single string with the formatted fields.
Format a fill value as a character string
Description
Format a fill value as a character string
Usage
.format_fill(x)
## Default S3 method:
.format_fill(x)
## S3 method for class 'Date'
.format_fill(x)
Arguments
x |
A fill value. |
Value
(character(1)) An R expression string representing x.
Format the .fill argument for display
Description
Format the .fill argument for display
Usage
.format_fill_arg(x, .fill)
Arguments
x |
A tibblify collector object. |
.fill |
( |
Value
(character(1) or NULL) The formatted fill string, or NULL if
the argument should be omitted.
Format a ptype object as a character string
Description
Format a ptype object as a character string
Usage
.format_ptype(x)
## Default S3 method:
.format_ptype(x)
## S3 method for class 'difftime'
.format_ptype(x)
## S3 method for class 'Date'
.format_ptype(x)
## S3 method for class 'POSIXct'
.format_ptype(x)
Arguments
x |
( |
Value
(character(1)) An R expression string representing x.
Format the .ptype argument for display
Description
Format the .ptype argument for display
Usage
.format_ptype_arg(x)
Arguments
x |
A tibblify collector object. |
Value
(character(1) or NULL) The formatted ptype string, or NULL if
the argument should be omitted.
Format the .ptype_inner argument for display
Description
Format the .ptype_inner argument for display
Usage
.format_ptype_inner(x, .ptype_inner)
Arguments
x |
A tibblify collector object. |
.ptype_inner |
( |
Value
(character(1) or NULL) The formatted .ptype string, or NULL
if the argument should be omitted.
Return the display function name for a collector
Description
Return the display function name for a collector
Usage
.format_tib_f(x)
## S3 method for class 'tib_unspecified'
.format_tib_f(x)
## S3 method for class 'tib_scalar_logical'
.format_tib_f(x)
## S3 method for class 'tib_scalar_integer'
.format_tib_f(x)
## S3 method for class 'tib_scalar_numeric'
.format_tib_f(x)
## S3 method for class 'tib_scalar_character'
.format_tib_f(x)
## S3 method for class 'tib_scalar_date'
.format_tib_f(x)
## S3 method for class 'tib_scalar_chr_date'
.format_tib_f(x)
## S3 method for class 'tib_scalar'
.format_tib_f(x)
## S3 method for class 'tib_vector_logical'
.format_tib_f(x)
## S3 method for class 'tib_vector_integer'
.format_tib_f(x)
## S3 method for class 'tib_vector_numeric'
.format_tib_f(x)
## S3 method for class 'tib_vector_character'
.format_tib_f(x)
## S3 method for class 'tib_vector_date'
.format_tib_f(x)
## S3 method for class 'tib_vector_chr_date'
.format_tib_f(x)
## S3 method for class 'tib_vector'
.format_tib_f(x)
## S3 method for class 'tib_variant'
.format_tib_f(x)
## S3 method for class 'tib_row'
.format_tib_f(x)
## S3 method for class 'tib_df'
.format_tib_f(x)
## S3 method for class 'tib_recursive'
.format_tib_f(x)
## Default S3 method:
.format_tib_f(x)
Arguments
x |
A tibblify collector object. |
Value
(character(1)) The (possibly ANSI-colored) function name string.
Build the formatted argument string for a collector call
Description
Build the formatted argument string for a collector call
Usage
.format_tib_parts(
f_name,
x,
...,
.fill = NULL,
.ptype_inner = NULL,
.transform = NULL,
multi_line = FALSE,
nchar_indent = 0,
width = NULL,
names = FALSE
)
Arguments
f_name |
( |
x |
A tibblify collector object. |
... |
Additional named arguments to include verbatim in the output,
forwarded from the calling |
.fill |
( |
.ptype_inner |
( |
.transform |
( |
multi_line |
( |
nchar_indent |
( |
width |
( |
names |
( |
Value
(character(1)) A string of comma-separated, possibly wrapped
arguments ready to be placed inside the parentheses of the collector call.
Prep unspecified paths for messaging
Description
Prep unspecified paths for messaging
Usage
.format_unspecified_paths(path_list, path = character())
Arguments
path_list |
( |
path |
( |
Value
The formatted paths as character.
Determine the type of an OpenAPI schema object
Description
Determine the type of an OpenAPI schema object
Usage
.get_openapi_type(schema)
Arguments
schema |
( |
Value
(character(1)) The type string, one of "object", "array",
"string", "integer", "boolean", "number", or "variant".
Find the common ptype of a list of objects
Description
Find the common ptype of a list of objects
Usage
.get_ptype_common(x, empty_list_unspecified)
Arguments
x |
( |
empty_list_unspecified |
( |
Value
A list with component has_common_ptype (TRUE if so, FALSE
otherwise) and optional components ptype (an object representing the
common ptype, if there is one) and had_empty_lists (TRUE if
empty_list_unspecified is TRUE and the x input had such empty lists).
Determine which fields are required in an object list
Description
Determine which fields are required in an object list
Usage
.get_required(x, sample_size = 10000)
Arguments
x |
( |
sample_size |
( |
Value
A named logical vector indicating which fields are present in every
element of x.
Find unspecified fields
Description
Find unspecified fields
Usage
.get_unspecified_paths(spec)
Arguments
spec |
( |
Value
A list of tib_unspecified() objects and objects containing
tib_unspecified() objects.
Guess the field spec for a single object field
Description
Dispatches to the appropriate helper based on the detected type of value.
Usage
.guess_object_field_spec(
value,
name,
empty_list_unspecified,
simplify_list,
local_env
)
Arguments
value |
( |
name |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
Value
A tib field specification.
Guess the field spec for a data-frame-typed field
Description
Guess the field spec for a data-frame-typed field
Usage
.guess_object_field_spec_df(value, name, empty_list_unspecified, local_env)
Arguments
value |
( |
name |
( |
empty_list_unspecified |
( |
local_env |
( |
Value
A tib_df field specification.
Expand an object list into a tib spec
Description
Expand an object list into a tib spec
Usage
.guess_object_field_spec_expand_fields(
value,
empty_list_unspecified,
simplify_list,
local_env,
...,
tib_fn = tib_df,
fields_fn = .guess_object_list_spec
)
Arguments
value |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
... |
Additional arguments passed to |
tib_fn |
( |
fields_fn |
( |
Value
A tib spec created by tib_fn.
Expand an object list into a tib_df spec
Description
Expand an object list into a tib_df spec
Usage
.guess_object_field_spec_expand_fields_df(
value,
empty_list_unspecified,
simplify_list,
local_env,
...,
tib_fn = tib_df
)
Arguments
value |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
... |
Additional arguments passed to |
tib_fn |
( |
Value
A tib_df() spec, with .names_to set when value is named and
non-empty.
Guess the field spec for a nested object field
Description
Guess the field spec for a nested object field
Usage
.guess_object_field_spec_object(
value,
name,
empty_list_unspecified,
simplify_list,
local_env
)
Arguments
value |
( |
name |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
Value
A tib_row field specification.
Guess the spec for an object list field
Description
Guess the spec for an object list field
Usage
.guess_object_field_spec_object_list(
value,
name,
empty_list_unspecified,
simplify_list,
local_env
)
Arguments
value |
( |
name |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
Value
A tib_df() spec keyed by name.
Guess the field spec for a vector-typed field
Description
Guess the field spec for a vector-typed field
Usage
.guess_object_field_spec_vector(value, name)
Arguments
value |
( |
name |
( |
Value
A tib field specification.
Guess the spec for a single field in an object list
Description
Guess the spec for a single field in an object list
Usage
.guess_object_list_field_spec(
value,
name,
empty_list_unspecified,
simplify_list,
local_env
)
Arguments
value |
( |
name |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
Value
A tib field spec.
Guess the spec for a list field without list simplification
Description
Guess the spec for a list field without list simplification
Usage
.guess_object_list_field_spec_dont_simplify(
value,
name,
empty_list_unspecified,
simplify_list,
local_env
)
Arguments
value |
( |
name |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
Value
A tib field spec.
Guess a vector spec from a flat list of field values
Description
Guess a vector spec from a flat list of field values
Usage
.guess_object_list_field_spec_flat_to_vector(value_flat, name, ptype_result)
Arguments
value_flat |
( |
name |
( |
ptype_result |
( |
Value
A tib_vector() spec.
Guess a row spec from an object list field
Description
Guess a row spec from an object list field
Usage
.guess_object_list_field_spec_object_list_row(
value,
name,
empty_list_unspecified,
simplify_list,
local_env
)
Arguments
value |
( |
name |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
Value
A tib_row() spec.
Guess the spec for a vector-typed field in an object list
Description
Guess the spec for a vector-typed field in an object list
Usage
.guess_object_list_field_spec_vector(
value,
name,
ptype,
had_empty_lists,
local_env
)
Arguments
value |
( |
name |
( |
ptype |
( |
had_empty_lists |
( |
local_env |
( |
Value
A tib_scalar() or tib_vector() spec.
Guess field specs for an object list
Description
Guess field specs for an object list
Usage
.guess_object_list_spec(
object_list,
empty_list_unspecified,
simplify_list,
local_env
)
Arguments
object_list |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
Value
A named list of tib field specs.
Guess whether a list field can be simplified to a vector spec
Description
Guess whether a list field can be simplified to a vector spec
Usage
.guess_vector_input_form(value, name)
Arguments
value |
( |
name |
( |
Value
A list with:
-
can_simplify(logical(1)): Whether the field can be simplified. -
tib_spec: A tib field specification (present only whencan_simplifyisTRUE).
Build a tib spec for a field-scalar input form
Description
Build a tib spec for a field-scalar input form
Usage
.guess_vector_input_form_field_scalar(value, name, ptype)
Arguments
value |
( |
name |
( |
ptype |
( |
Value
A list with can_simplify = TRUE and tib_spec, a tib_vector
field specification.
Guess input form for a list field whose common ptype is NULL
Description
Guess input form for a list field whose common ptype is NULL
Usage
.guess_vector_input_form_null(value, name)
Arguments
value |
( |
name |
( |
Value
A list with:
-
can_simplify(logical(1)): Whether the field can be simplified. -
tib_spec: A tib field specification (present only whencan_simplifyisTRUE).
Apply column-to-spec conversion across a data frame
Description
Apply column-to-spec conversion across a data frame
Usage
.imap_col_to_spec(col_list, empty_list_unspecified, local_env)
Arguments
col_list |
( |
empty_list_unspecified |
( |
local_env |
( |
Value
A named list of tib field specifications.
Map .guess_object_field_spec over a named list
Description
Map .guess_object_field_spec over a named list
Usage
.imap_guess_object_field_spec(
x,
empty_list_unspecified,
simplify_list,
local_env
)
Arguments
x |
( |
empty_list_unspecified |
( |
simplify_list |
( |
local_env |
( |
Value
A named list of tib field specifications, one per element of x.
Is every element of a field scalar?
Description
Is every element of a field scalar?
Usage
.is_field_scalar(value)
Arguments
value |
( |
Value
TRUE if every element has size 1 or is NULL, FALSE otherwise.
Is x a list of NULLs?
Description
Is x a list of NULLs?
Usage
.is_list_of_null(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if every element of x is NULL, FALSE
otherwise.
Is x a list of object lists?
Description
Is x a list of object lists?
Usage
.is_list_of_object_lists(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if every non-NULL element of x is a list
of objects, FALSE otherwise.
Is x an object?
Description
Is x an object?
Usage
.is_object(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if x is an object (a fully named list with
unique names), FALSE otherwise.
Is x a list of objects?
Description
Is x a list of objects?
Usage
.is_object_list(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if x is a list of objects, FALSE
otherwise.
Check if object is a tib collector
Description
Check if object is a tib collector
Usage
.is_tib(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if x is a tib_collector.
Check if a tib field has a canonical name
Description
Check if a tib field has a canonical name
Usage
.is_tib_name_canonical(field, name)
Arguments
field |
( |
name |
( |
Value
TRUE if the field's key is a single string that matches name,
FALSE otherwise.
Check if object is a tib row
Description
Check if object is a tib row
Usage
.is_tib_row(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if x is a tib_row.
Check if object is a tib scalar
Description
Check if object is a tib scalar
Usage
.is_tib_scalar(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if x is a tib_scalar.
Check if object is a tib unspecified
Description
Check if object is a tib unspecified
Usage
.is_tib_unspecified(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if x is a tib_unspecified.
Check if object is a tib variant
Description
Check if object is a tib variant
Usage
.is_tib_variant(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if x is a tib_variant.
Check if object is a tib vector
Description
Check if object is a tib vector
Usage
.is_tib_vector(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if x is a tib_vector.
Check if object is a tibblify specification
Description
Check if object is a tibblify specification
Usage
.is_tspec(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if x is a tspec object.
Is the object unspecified?
Description
Is the object unspecified?
Usage
.is_unspecified(x)
Arguments
x |
( |
Value
TRUE if the object has class "vctrs_unspecified", FALSE
otherwise.
Check whether input is an http(s) URL string
Description
Check whether input is an http(s) URL string
Usage
.is_url_string(x, arg = caller_arg(x), call = caller_env())
Arguments
x |
( |
arg |
( |
call |
( |
Value
(logical(1)) TRUE for scalar strings starting with http:// or
https://, FALSE otherwise.
Is the object a vector?
Description
Is the object a vector?
Usage
.is_vec(x)
Arguments
x |
( |
Value
TRUE if the object is a non-list vector, FALSE otherwise.
Convert a logical vector to cli bullet symbols
Description
Convert a logical vector to cli bullet symbols
Usage
.lgl_to_bullet(x)
Arguments
x |
( |
Value
(character) A character vector of cli bullet names ("v" or
"x") the same length as x.
Convert a list column to a tib field specification
Description
Inspects the elements of col to determine whether they share a common ptype
and dispatches to the appropriate spec builder.
Usage
.list_col_to_spec(col, name, empty_list_unspecified, local_env)
Arguments
col |
( |
name |
( |
empty_list_unspecified |
( |
local_env |
( |
Value
A tib field specification.
For each element, is it a list of NULLs?
Description
For each element, is it a list of NULLs?
Usage
.list_is_list_of_null(x)
Arguments
x |
( |
Value
(logical) A logical vector the same length as x, where each
element is TRUE if the corresponding element of x is itself a list of
NULLs.
Build field specs from a list_of df column
Description
Build field specs from a list_of df column
Usage
.list_of_col_to_spec_df(col, ptype, empty_list_unspecified, local_env)
Arguments
col |
( |
ptype |
( |
empty_list_unspecified |
( |
local_env |
( |
Value
A named list of tib field specifications.
Format location names and types
Description
Format location names and types
Usage
.loc_name_helper(locs, types)
Arguments
locs |
( |
types |
( |
Value
(character) Dot-prefixed location names and types.
Mark that the empty list argument was used
Description
Mark that the empty list argument was used
Usage
.mark_empty_list_argument(used_empty_list_arg, local_env)
Arguments
used_empty_list_arg |
( |
local_env |
( |
Value
Called for its side effect of setting local_env$empty_list_used to
TRUE when used_empty_list_arg is TRUE.
Potentially inform users about unspecified fields
Description
Potentially inform users about unspecified fields
Usage
.maybe_inform_unspecified(spec, inform_unspecified, call = caller_env())
Arguments
spec |
( |
inform_unspecified |
( |
call |
( |
Value
The spec object.
Collapse expressions with padding and optional multi-line formatting
Description
Collapse expressions with padding and optional multi-line formatting
Usage
.name_exprs(exprs, names, show_name)
Arguments
exprs |
( |
names |
( |
show_name |
( |
Value
A character vector of the expressions with names prepended where
show_name is TRUE. Non-syntactic names are backticked. If show_name
is FALSE, the expressions are returned without names.
Calculate the number of characters in a field's name part
Description
Calculate the number of characters in a field's name part
Usage
.nchar_field_names(fields)
Arguments
fields |
( |
Value
An integer vector of the number of characters in the name part of each field, including the "=" separator and a trailing comma.
Main implementation of tree nesting
Description
Main implementation of tree nesting
Usage
.nest_tree_impl(
x,
id_col,
parent_col,
children_to,
id_col_name,
call = caller_env()
)
Arguments
x |
( |
id_col |
( |
parent_col |
( |
children_to |
( |
id_col_name |
( |
call |
( |
Value
A nested data frame with children column and parent column removed.
Compute tree level for each element based on id and parent relationships
Description
Compute tree level for each element based on id and parent relationships
Usage
.nest_tree_lvl(ids, parent_ids, id_col_name, call = caller_env())
Arguments
ids |
( |
parent_ids |
( |
id_col_name |
( |
call |
( |
Value
A list with lvls (integer vector of levels) and max_lvl (maximum
level).
Build field specs from a non-list_of df column
Description
Build field specs from a non-list_of df column
Usage
.non_list_of_col_to_spec_df(col, ptype, empty_list_unspecified, local_env)
Arguments
col |
( |
ptype |
( |
empty_list_unspecified |
( |
local_env |
( |
Value
A named list of tib field specifications with required set.
Resolve child_col to a column name string
Description
Resolve child_col to a column name string
Usage
.normalize_child_col_name(child_col, x, id_col, call = caller_env())
Arguments
child_col |
( |
x |
( |
id_col |
( |
call |
( |
Value
child_col resolved to a character(1) column name.
Normalize and check the id column
Description
Normalize and check the id column
Usage
.normalize_id_col(id_col, x, call = caller_env())
Arguments
id_col |
( |
x |
( |
call |
( |
Value
The integer index of the id column.
Resolve id_col to a column name string
Description
Resolve id_col to a column name string
Usage
.normalize_id_col_name(id_col, x, call = caller_env())
Arguments
id_col |
( |
x |
( |
call |
( |
Value
id_col resolved to a character(1) column name.
Normalize and check the parent column
Description
Normalize and check the parent column
Usage
.normalize_parent_col(parent_col, x, id_col, id_col_name, call = caller_env())
Arguments
parent_col |
( |
x |
( |
id_col |
( |
id_col_name |
( |
call |
( |
Value
The integer index of the parent column.
Resolve $ref references in an OpenAPI schema object
Description
Resolve $ref references in an OpenAPI schema object
Usage
.openapi_resolve_reference(schema, openapi_spec)
Arguments
schema |
( |
openapi_spec |
( |
Value
(list) The schema with all $ref references resolved.
Pad a character vector with a specified number of spaces
Description
Pad a character vector with a specified number of spaces
Usage
.pad(x, n)
Arguments
x |
( |
n |
( |
Value
A character vector with each element of x prepended with n
spaces. If an element of x contains newlines, each line will be prepended
with n spaces.
Parse a named list of header objects from an OpenAPI spec
Description
Parse a named list of header objects from an OpenAPI spec
Usage
.parse_header_objects(header_objects, openapi_spec)
Arguments
header_objects |
( |
openapi_spec |
( |
Value
(tbl_df) A tibble of parsed header objects.
Parse a named list of media type objects from an OpenAPI spec
Description
Parse a named list of media type objects from an OpenAPI spec
Usage
.parse_media_type_objects(media_type_objects, openapi_spec)
Arguments
media_type_objects |
( |
openapi_spec |
( |
Value
(tbl_df) A tibble with media_type and spec columns.
Parse an operation object from an OpenAPI spec
Description
Parse an operation object from an OpenAPI spec
Usage
.parse_operation_object(operation_object, openapi_spec)
Arguments
operation_object |
( |
openapi_spec |
( |
Value
A one-row tibble describing the operation.
Parse a list of parameter objects from an OpenAPI spec
Description
Parse a list of parameter objects from an OpenAPI spec
Usage
.parse_parameters(parameters, openapi_spec)
Arguments
parameters |
( |
openapi_spec |
( |
Value
(tbl_df or NULL) A tibble of parsed parameters, or NULL if
parameters is NULL.
Parse a path item object from an OpenAPI spec
Description
Parse a path item object from an OpenAPI spec
Usage
.parse_path_item_object(path_item_object, openapi_spec)
Arguments
path_item_object |
( |
openapi_spec |
( |
Value
A tibble of parsed operations with a global_parameters column.
Parse all path item objects from an OpenAPI spec
Description
Parse all path item objects from an OpenAPI spec
Usage
.parse_path_item_objects(openapi_spec)
Arguments
openapi_spec |
( |
Value
A named list of tibbles, one per path, containing parsed operations.
Parse a request body object from an OpenAPI spec
Description
Parse a request body object from an OpenAPI spec
Usage
.parse_request_body(request_body, openapi_spec)
Arguments
request_body |
( |
openapi_spec |
( |
Value
(tspec_row or NULL) A parsed request body row spec, or NULL
if request_body is NULL.
Parse a single response object from an OpenAPI spec
Description
Parse a single response object from an OpenAPI spec
Usage
.parse_response_object(response_object, openapi_spec)
Arguments
response_object |
( |
openapi_spec |
( |
Value
(tbl_df) A one-row tibble describing the response.
Parse a responses object from an OpenAPI spec
Description
Parse a responses object from an OpenAPI spec
Usage
.parse_responses_object(responses_object, openapi_spec)
Arguments
responses_object |
( |
openapi_spec |
( |
Value
(tbl_df) A tibble of parsed response objects with a status_code
column.
Parse an OpenAPI schema object into a tib field spec
Description
Parse an OpenAPI schema object into a tib field spec
Usage
.parse_schema(schema, name, openapi_spec)
Arguments
schema |
( |
name |
( |
openapi_spec |
( |
Value
A tib field spec corresponding to the schema type.
Pad and collapse a character vector across multiple lines
Description
Pad and collapse a character vector across multiple lines
Usage
.paste_multiline(x)
Arguments
x |
( |
Value
A single string with the elements of x padded and collapsed across
multiple lines, with a leading newline and a trailing comma on each line.
Convert a path object to a printable string
Description
Convert a path object to a printable string
Usage
.path_to_string(path)
Arguments
path |
( |
Value
(character(1)) A string path such as "x$a[[1]]".
Prepare a complex field
Description
Prepare a complex field
Usage
.prep_complex_field(key, spec_fields)
Arguments
key |
( |
spec_fields |
( |
Value
A prepared field specification.
Prepare nested keys in a tibblify specification
Description
Prepare nested keys in a tibblify specification
Usage
.prep_nested_keys(spec_fields, coll_locations)
Arguments
spec_fields |
( |
coll_locations |
( |
Value
A list with prepared fields, keys, and locations.
Prepare a simple field
Description
Prepare a simple field
Usage
.prep_simple_field(x)
Arguments
x |
( |
Value
A prepared field specification.
Flatten, validate, and auto-name field specifications
Description
Flatten, validate, and auto-name field specifications
Usage
.prep_spec_fields(.fields, .error_call)
Arguments
.fields |
( |
.error_call |
( |
Value
A named list of validated field specifications.
Prepare the fill value for a vector field
Description
Prepare the fill value for a vector field
Usage
.prep_tib_fill(fill, names_to, col_names)
Arguments
fill |
( |
names_to |
( |
col_names |
( |
Value
The existing fill value, or a tibble representing the fill.
Prepare the ptype list for a vector field
Description
Prepare the ptype list for a vector field
Usage
.prep_tib_list_of_ptype(ptype, names_to, col_names)
Arguments
ptype |
( |
names_to |
( |
col_names |
( |
Value
A tibble representing the ptype.
Prepare a scalar field
Description
Prepare a scalar field
Usage
.prep_tib_scalar(x)
Arguments
x |
( |
Value
A prepared scalar field specification.
Prepare a vector field
Description
Prepare a vector field
Usage
.prep_tib_vector(x)
Arguments
x |
( |
Value
A prepared vector field specification.
Prepare transform function
Description
Prepare transform function
Usage
.prep_transform(f, .call, arg = ".transform")
Arguments
f |
( |
.call |
( |
arg |
( |
Value
(function or NULL) The prepared function.
Process complex fields (depth > 1)
Description
Process complex fields (depth > 1)
Usage
.process_complex_fields(spec_fields, first_keys)
Arguments
spec_fields |
( |
first_keys |
( |
Value
A list of prepared fields.
Process simple fields (depth 1)
Description
Process simple fields (depth 1)
Usage
.process_simple_fields(spec_fields)
Arguments
spec_fields |
( |
Value
A list of prepared fields.
Read whether the empty list argument was used
Description
Read whether the empty list argument was used
Usage
.read_empty_list_argument(local_env)
Arguments
local_env |
( |
Value
TRUE if local_env$empty_list_used is TRUE, FALSE otherwise.
Read an OpenAPI schema from a file, connection, or list
Description
Read an OpenAPI schema from a file, connection, or list
Usage
.read_schema(file, arg = caller_arg(file), call = caller_env())
Arguments
file |
( |
arg |
( |
call |
( |
Value
(list) The parsed schema.
Read an OpenAPI spec from a file, connection, or list
Description
Read an OpenAPI spec from a file, connection, or list
Usage
.read_spec(file, arg = caller_arg(file), call = caller_env())
Arguments
file |
( |
arg |
( |
call |
( |
Value
(list) The parsed spec.
Read an OpenAPI spec or schema from a file, connection, or list
Description
Read an OpenAPI spec or schema from a file, connection, or list
Usage
.read_spec_impl(file, arg = caller_arg(file), call = caller_env())
## S3 method for class 'list'
.read_spec_impl(file, ...)
## S3 method for class 'connection'
.read_spec_impl(file, ...)
## S3 method for class 'character'
.read_spec_impl(file, arg = caller_arg(file), call = caller_env())
## Default S3 method:
.read_spec_impl(file, arg = caller_arg(file), call = caller_env())
Arguments
file |
( |
arg |
( |
call |
( |
Value
(list) The parsed spec or schema.
Reduce per-level data frames to their combined ptype
Description
Reduce per-level data frames to their combined ptype
Usage
.reduce_ptype(snapshots, call)
Arguments
snapshots |
( |
call |
( |
Value
A 0-row data frame representing the combined type of all levels.
Remove the first key from a field
Description
Remove the first key from a field
Usage
.remove_first_key(x)
Arguments
x |
( |
Value
The field specification with the first key removed.
Check whether any nested list element has a $ref key
Description
Check whether any nested list element has a $ref key
Usage
.schema_has_ref(x)
Arguments
x |
( |
Value
(logical(1)) TRUE if any element has a $ref key.
Set the tibblify specification attribute
Description
Set the tibblify specification attribute
Usage
.set_spec(x, spec)
Arguments
x |
( |
spec |
( |
Value
The object x with the tib_spec attribute set.
Shared parameters
Description
These parameters are used in multiple functions. They are defined here to make them easier to import and to find.
Arguments
allow_null |
( |
arg |
( |
.call |
( |
.children |
( |
.children_to |
( |
col |
( |
col_name |
( |
elt |
( |
.elt_transform |
( |
empty_list_unspecified |
( |
env |
( |
.error_call |
( |
expr |
( |
f_name |
( |
field_spec |
( |
file |
( |
.fill |
( |
force_names |
( |
.format |
( |
header_objects |
( |
id_col |
( |
id_col_name |
( |
index |
( |
inform_unspecified |
( |
input_form |
( |
.key |
( |
local_env |
( |
media_type_object |
( |
media_type_objects |
( |
message |
( |
multi_line |
( |
name |
( |
name_spec |
( |
names |
( |
nchar_indent |
( |
openapi_spec |
( |
operation_object |
( |
parameters |
( |
parent_col |
( |
path |
( |
path_exp |
( |
path_item_object |
( |
.ptype |
( |
.ptype_inner |
( |
request_body |
( |
.required |
( |
response_object |
( |
responses_object |
( |
schema |
( |
simplify_list |
( |
size_act |
( |
size_exp |
( |
spec |
( |
spec_list |
( |
tib_list |
( |
.transform |
( |
value |
( |
.values_to |
( |
width |
( |
x |
( |
x_arg |
( |
Shared spec_prep parameters
Description
These parameters are used in multiple .spec_prep()-related functions. They
are defined here to make them easier to import and to find. This break-out is
for parameters that may differ from other functions that use the same
parameter names.
Arguments
coll_locations |
( |
field_spec |
( |
fill |
( |
first_keys |
( |
key |
( |
spec_fields |
( |
x |
( |
ptype |
( |
names_to |
( |
col_names |
( |
Shared tib_spec parameters
Description
These parameters are used in multiple tib_*() functions. They are defined
here to make them easier to import and to find, and to make sure the
deprecated forms get documented identically when these definitions are
imported. This break-out is for parameters that differ between tib_*()
functions and other functions that use the same parameters.
Arguments
.input_form |
(
|
.names_to |
(
|
Shared (un)nest_tree parameters
Description
These parameters are used in multiple nest_tree() or unnest_tree()
helpers. They are defined here to make them easier to import and to find.
This break-out is for parameters that differ between (un)nest_tree()
helpers and other functions that might use the same parameters.
Arguments
col |
( |
col_arg |
( |
ids |
( |
parent_ids |
( |
Determine whether to print names for tibblifying
Description
Determine whether to print names for tibblifying
Usage
.should_force_names()
Value
A logical value indicating whether to print names for tibblifying,
based on the tibblify.print_names option.
Sort specification by the first key
Description
Sort specification by the first key
Usage
.sort_spec_by_first_key(spec_fields, coll_locations)
Arguments
spec_fields |
( |
coll_locations |
( |
Value
A list with sorted components.
Auto-name fields based on their key attribute
Description
Auto-name fields based on their key attribute
Usage
.spec_auto_name_fields(.fields, .error_call)
Arguments
.fields |
( |
.error_call |
( |
Value
A named list of field specifications.
Inform about or error for unspecified fields
Description
Inform about or error for unspecified fields
Usage
.spec_inform_unspecified(spec, unspecified = "inform", call = caller_env())
Arguments
spec |
( |
unspecified |
(
|
call |
( |
Value
The original spec, invisibly.
Prepare a tibblify specification for tibblification
Description
Prepare a tibblify specification for tibblification
Usage
.spec_prep(spec)
Arguments
spec |
( |
Value
A prepared tibblify specification.
Prepare a non-recursive tibblify specification
Description
Prepare a non-recursive tibblify specification
Usage
.spec_prep_nonrecursive(spec)
Arguments
spec |
( |
Value
A prepared tibblify specification.
Prepare a recursive tibblify specification
Description
Prepare a recursive tibblify specification
Usage
.spec_prep_recursive(spec)
Arguments
spec |
( |
Value
A prepared tibblify specification.
Prepare unspecified fields
Description
Prepare unspecified fields
Usage
.spec_prep_unspecified(spec, unspecified, call = caller_env())
Arguments
spec |
( |
unspecified |
(
|
call |
( |
Value
A prepared tibblify specification.
Replace unspecified fields in the specification
Description
Replace unspecified fields in the specification
Usage
.spec_replace_unspecified(spec, unspecified)
Arguments
spec |
( |
unspecified |
(
|
Value
A modified tibblify specification.
Replace unspecified fields in the specification
Description
Replace unspecified fields in the specification
Usage
.spec_replace_unspecified_impl(spec_fields, unspecified)
Arguments
spec_fields |
( |
unspecified |
(
|
Value
A modified list of tib_collector objects.
Replace tib_unspecified fields in the specification
Description
Replace tib_unspecified fields in the specification
Usage
.spec_replace_unspecified_type(field_spec, unspecified)
Arguments
field_spec |
( |
unspecified |
(
|
Value
A modified tib_collector.
Stabilize names_to argument
Description
Stabilize names_to argument
Usage
.stabilize_names_to(.names_to, .values_to, .input_form, .call)
Arguments
.names_to |
(
|
.values_to |
( |
.input_form |
(
|
.call |
( |
Value
(character(1) or NULL) Validated .names_to.
Check which fields to unpack
Description
Check which fields to unpack
Usage
.stabilize_unpack_cols(fields, spec, .call = caller_env())
Arguments
fields |
( |
spec |
( |
.call |
( |
Value
(character) The names of the fields to unpack.
Stabilize values_to argument
Description
Stabilize values_to argument
Usage
.stabilize_values_to(.values_to, .call)
Arguments
.values_to |
( |
.call |
( |
Value
(character(1) or NULL) Validated .values_to.
Error for NULL in colmajor fields
Description
Error for NULL in colmajor fields
Usage
.stop_colmajor_null(path)
Arguments
path |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for inconsistent colmajor field sizes
Description
Error for inconsistent colmajor field sizes
Usage
.stop_colmajor_wrong_size_element(path, size_act, path_exp, size_exp)
Arguments
path |
( |
size_act |
( |
path_exp |
( |
size_exp |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for duplicate names
Description
Error for duplicate names
Usage
.stop_duplicate_name(path, name)
Arguments
path |
( |
name |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for empty names
Description
Error for empty names
Usage
.stop_empty_name(path, index)
Arguments
path |
( |
index |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for unnamed object
Description
Error for unnamed object
Usage
.stop_names_is_null(path)
Arguments
path |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for non-list element
Description
Error for non-list element
Usage
.stop_non_list_element(path, x)
Arguments
path |
( |
x |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for unnamed object vector
Description
Error for unnamed object vector
Usage
.stop_object_vector_names_is_null(path)
Arguments
path |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for missing required field
Description
Error for missing required field
Usage
.stop_required(path)
Arguments
path |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for missing required colmajor field
Description
Error for missing required colmajor field
Usage
.stop_required_colmajor(path)
Arguments
path |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for non-scalar field
Description
Error for non-scalar field
Usage
.stop_scalar(path, size_act)
Arguments
path |
( |
size_act |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for non-list vector element
Description
Error for non-list vector element
Usage
.stop_vector_non_list_element(path, input_form, x)
Arguments
path |
( |
input_form |
( |
x |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Error for wrong-sized vector element
Description
Error for wrong-sized vector element
Usage
.stop_vector_wrong_size_element(path, input_form, x)
Arguments
path |
( |
input_form |
( |
x |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Create a tib collector
Description
Create a tib collector
Usage
.tib_collector(
.key,
.type,
...,
.required = TRUE,
.class = NULL,
.transform = NULL,
.elt_transform = NULL,
.call = caller_env()
)
Arguments
.key |
( |
.type |
( |
.required |
( |
.class |
( |
.transform |
( |
.elt_transform |
( |
.call |
( |
Value
(tib_collector) A tibblify collector.
Combine a list of tib fields
Description
Combine a list of tib fields
Usage
.tib_combine(tib_list, name, .call)
Arguments
tib_list |
( |
name |
( |
.call |
( |
Value
(tib_collector) A combined tibblify field collector.
Combine dataframe tib fields
Description
Combine dataframe tib fields
Usage
.tib_combine_df(tib_list, type, key, required, .call)
Arguments
tib_list |
( |
type |
( |
key |
( |
required |
( |
.call |
( |
Value
(tib_row or tib_df) A tibblify dataframe field collector.
Combine fill values from a list of tibs
Description
Combine fill values from a list of tibs
Usage
.tib_combine_fill(tib_list, type, ptype, .call)
Arguments
tib_list |
( |
type |
( |
ptype |
( |
.call |
( |
Value
(vector) The combined fill value.
Combine input forms from a list of tibs
Description
Combine input forms from a list of tibs
Usage
.tib_combine_input_form(tib_list, .call)
Arguments
tib_list |
( |
.call |
( |
Value
(character(1)) The combined input form.
Combine keys from a list of tibs
Description
Combine keys from a list of tibs
Usage
.tib_combine_key(tib_list, name, .call)
Arguments
tib_list |
( |
name |
( |
.call |
( |
Value
(character(1)) The combined key.
Combine names_col value from a list of tibs
Description
Combine names_col value from a list of tibs
Usage
.tib_combine_names_col(tib_list, .call)
Arguments
tib_list |
( |
.call |
( |
Value
(character(1) or NULL) The combined names column.
Combine ptypes from a list of tibs
Description
Combine ptypes from a list of tibs
Usage
.tib_combine_ptype(tib_list, .call)
Arguments
tib_list |
( |
.call |
( |
Value
(vector(0)) The combined ptype.
Combine required status from a list of tibs
Description
Combine required status from a list of tibs
Usage
.tib_combine_required(tib_list)
Arguments
tib_list |
( |
Value
(logical(1)) The combined required status.
Combine various specified tib field types
Description
Combine various specified tib field types
Usage
.tib_combine_specified(tib_list, type, key, required, .call)
Arguments
tib_list |
( |
type |
( |
key |
( |
required |
( |
.call |
( |
Value
(tib_variant, tib_scalar, or tib_vector) A tibblify field
collector.
Combine transform functions from a list of tibs
Description
Combine transform functions from a list of tibs
Usage
.tib_combine_transform(tib_list, .call)
Arguments
tib_list |
( |
.call |
( |
Value
(function or NULL) The combined transform function.
Combine types from a list of tibs
Description
Combine types from a list of tibs
Usage
.tib_combine_type(tib_list, .call)
Arguments
tib_list |
( |
.call |
( |
Value
(character(1)) The combined tib type.
Combine vector tib fields
Description
Combine vector tib fields
Usage
.tib_combine_vector(tib_list, key, ptype, required, fill, transform, .call)
Arguments
tib_list |
( |
key |
( |
ptype |
( |
required |
( |
fill |
( |
transform |
( |
.call |
( |
Value
(tib_vector) A tibblify vector field collector.
Combine allOf sub-schemas into a tib field
Description
Combine allOf sub-schemas into a tib field
Usage
.tib_from_all_of(schema, name, openapi_spec)
Arguments
schema |
( |
name |
( |
openapi_spec |
( |
Value
A combined tib field spec.
Combine anyOf sub-schemas into a tib field
Description
Combine anyOf sub-schemas into a tib field
Usage
.tib_from_any_of(schema, name, openapi_spec)
Arguments
schema |
( |
name |
( |
openapi_spec |
( |
Value
A combined tib field spec, or tib_variant() if schemas are
incompatible.
Combine oneOf sub-schemas into a tib field
Description
Combine oneOf sub-schemas into a tib field
Usage
.tib_from_one_of(schema, name, openapi_spec)
Arguments
schema |
( |
name |
( |
openapi_spec |
( |
Value
A combined tib field spec, or tib_variant() if schemas are
incompatible.
Parse an array-type OpenAPI schema and create a tib field
Description
Parse an array-type OpenAPI schema and create a tib field
Usage
.tib_from_schema_array(schema, name, openapi_spec)
Arguments
schema |
( |
name |
( |
openapi_spec |
( |
Value
A tib field spec for the array, which may be a vector, data frame, or variant field depending on the array items schema.
Parse an object-type OpenAPI schema and create a tib field
Description
Parse an object-type OpenAPI schema and create a tib field
Usage
.tib_from_schema_object(schema, name, openapi_spec)
Arguments
schema |
( |
name |
( |
openapi_spec |
( |
Value
A tib_row() field spec with fields extracted from schema
properties.
Parse an OpenAPI schema type and create a tib field
Description
Parse an OpenAPI schema type and create a tib field
Usage
.tib_from_schema_type(schema, name, openapi_spec)
Arguments
schema |
( |
name |
( |
openapi_spec |
( |
Value
A tib field spec corresponding to the schema type.
Get the ptype of an object
Description
Get the ptype of an object
Usage
.tib_ptype(x)
Arguments
x |
( |
Value
The ptype of x, with POSIXlt coerced to POSIXct.
Implementation of tib_scalar
Description
Implementation of tib_scalar
Usage
.tib_scalar_impl(
.key,
.ptype,
...,
.required = TRUE,
.fill = vctrs::vec_init(.ptype_inner),
.ptype_inner = .ptype,
.transform = NULL,
.class = NULL,
.call = caller_env()
)
Arguments
.key |
( |
.ptype |
( |
.required |
( |
.fill |
( |
.ptype_inner |
( |
.transform |
( |
.class |
( |
.call |
( |
Value
(tib_scalar) A tibblify scalar collector.
Create a scalar or vector tib spec
Description
Create a scalar or vector tib spec
Usage
.tib_scalar_or_vector_spec(name, ptype, is_scalar)
Arguments
name |
( |
ptype |
( |
is_scalar |
( |
Value
A tib_scalar() or tib_vector() spec.
Determine the tib type of an object
Description
Determine the tib type of an object
Usage
.tib_type_of(x, name, other)
Arguments
x |
( |
name |
( |
other |
( |
Value
One of "df", "list", "vector", or "other".
Implementation of tib_vector
Description
Implementation of tib_vector
Usage
.tib_vector_impl(
.key,
.ptype,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = .ptype,
.transform = NULL,
.elt_transform = NULL,
.input_form = c("vector", "scalar_list", "object"),
.values_to = NULL,
.names_to = NULL,
.class = NULL,
.call = caller_env()
)
Arguments
.key |
( |
.ptype |
( |
.required |
( |
.fill |
( |
.ptype_inner |
( |
.transform |
( |
.elt_transform |
( |
.input_form |
(
|
.values_to |
( |
.names_to |
(
|
.class |
( |
.call |
( |
Value
(tib_vector) A tibblify vector collector.
Determine the vector input form of a value
Description
Determine the vector input form of a value
Usage
.tib_vector_input_form(value)
Arguments
value |
( |
Value
"object" if value is named, "scalar_list" otherwise.
Throw a tibblify internal error
Description
Throw a tibblify internal error
Usage
.tibblify_abort(..., .envir = caller_env())
Arguments
... |
Arguments passed to |
.envir |
( |
Value
NULL (invisibly). Called for its side effect of throwing an error.
Tibblify implementation
Description
Tibblify implementation
Usage
.tibblify_impl(x, spec, path)
Arguments
x |
( |
spec |
( |
path |
( |
Value
Either a tibble or a list, depending on the specification.
Get the width for tibblifying
Description
Get the width for tibblifying
Usage
.tibblify_width(width = NULL)
Arguments
width |
( |
Value
The width to use for tibblifying, either the provided width or the
value of the width option if width is NULL.
Tibblify implementation with error handling
Description
Tibblify implementation with error handling
Usage
.try_tibblify_impl(x, spec, call = caller_env())
Arguments
x |
( |
spec |
( |
call |
( |
Value
Either a tibble or a list, depending on the specification.
Create a tibblify specification object
Description
Create a tibblify specification object
Usage
.tspec(
.fields,
.type,
...,
.vector_allows_empty_list = FALSE,
.error_call = caller_env()
)
Arguments
.fields |
( |
.type |
( |
... |
Additional specification attributes passed to |
.error_call |
( |
Value
A tspec object with class tspec_<type> and tspec.
Combine fields from a list of specs
Description
Combine fields from a list of specs
Usage
.tspec_combine_field_list(spec_list, .call)
Arguments
spec_list |
( |
.call |
( |
Value
(list) A list of combined fields generated by .tib_combine().
Combine allOf sub-schemas into a tspec
Description
Combine allOf sub-schemas into a tspec
Usage
.tspec_from_all_of(schema, openapi_spec)
Arguments
schema |
( |
openapi_spec |
( |
Value
A tspec_combine(), or NULL if schema$allOf is empty.
Combine oneOf sub-schemas into a tspec
Description
Combine oneOf sub-schemas into a tspec
Usage
.tspec_from_one_of(schema, openapi_spec)
Arguments
schema |
( |
openapi_spec |
( |
Value
A tspec_combine(), or tib_variant("dummy") if schemas are
incompatible, or NULL if schema$oneOf is empty.
Convert an OpenAPI schema to a tibblify tspec
Description
Convert an OpenAPI schema to a tibblify tspec
Usage
.tspec_from_schema(schema, openapi_spec)
Arguments
schema |
( |
openapi_spec |
( |
Value
A tibblify spec (tspec_row(), tspec_df(), or a tib field).
Convert an array-type schema to a tibblify data frame spec
Description
Convert an array-type schema to a tibblify data frame spec
Usage
.tspec_from_schema_array(schema, openapi_spec)
Arguments
schema |
( |
openapi_spec |
( |
Value
A tspec_df() spec with fields extracted from the array items
schema properties.
Convert an object-type schema to a tibblify row spec
Description
Convert an object-type schema to a tibblify row spec
Usage
.tspec_from_schema_object(schema, openapi_spec)
Arguments
schema |
( |
openapi_spec |
( |
Value
A tspec_row() spec with fields extracted from schema properties.
Choose and apply a tspec_from_schema_type function
Description
Choose and apply a tspec_from_schema_type function
Usage
.tspec_from_schema_type(schema, openapi_spec)
Arguments
schema |
( |
openapi_spec |
( |
Value
A tibblify spec (tspec_row(), tspec_df(), or a tib field).
Unclass and unchop a list of child data frames
Description
Unclass and unchop a list of child data frames
Usage
.unchop_children(children, child_col, call = caller_env())
Arguments
children |
( |
child_col |
( |
call |
( |
Value
(data.frame) All non-NULL children combined into one data frame.
Unchop and repair fields
Description
Unchop and repair fields
Usage
.unchop_fields(fields, names_repair, names_clean, .call = caller_env())
Arguments
fields |
( |
names_repair |
(
|
names_clean |
( |
.call |
( |
Value
(list) A list of unchopped and repaired fields.
Unclass a list_of child data frame
Description
Unclass a list_of child data frame
Usage
.unclass_list_of(x, child_col, call = caller_env())
Arguments
x |
( |
child_col |
( |
call |
( |
Value
(data.frame or NULL) x with vctrs_list_of classes removed,
or NULL if x is NULL.
Unpack a single field
Description
Unpack a single field
Usage
.unpack_field(
field_spec,
recurse,
name,
names_sep,
names_repair,
names_clean,
.call
)
Arguments
field_spec |
( |
recurse |
( |
name |
( |
names_sep |
( |
names_repair |
(
|
names_clean |
( |
.call |
( |
Value
(list) A list of unpacked fields.
Recursively unpack a field
Description
Recursively unpack a field
Usage
.unpack_field_recursive(
field_spec,
recurse,
names_sep,
names_repair,
names_clean,
.call
)
Arguments
field_spec |
( |
recurse |
( |
names_sep |
( |
names_repair |
(
|
names_clean |
( |
.call |
( |
Value
(tib_collector) The field spec with updated sub-fields.
Unpack a row field
Description
Unpack a row field
Usage
.unpack_field_row(field_spec, name, names_sep)
Arguments
field_spec |
( |
name |
( |
names_sep |
( |
Value
(list) A list of unpacked fields from the row spec.
Unpack and repair fields
Description
Unpack and repair fields
Usage
.unpack_fields(
spec,
fields,
recurse,
names_sep,
names_repair,
names_clean,
.call = caller_env()
)
Arguments
spec |
( |
fields |
( |
recurse |
( |
names_sep |
( |
names_repair |
(
|
names_clean |
( |
.call |
( |
Value
(list) A list of unpacked fields.
Unpack all fields in a spec
Description
Unpack all fields in a spec
Usage
.unpack_fields_impl(
spec,
fields,
recurse,
names_sep,
names_repair,
names_clean,
.call = caller_env()
)
Arguments
spec |
( |
fields |
( |
recurse |
( |
names_sep |
( |
names_repair |
(
|
names_clean |
( |
.call |
( |
Value
(list) A list of unpacked fields (still nested in a list
structure).
Update the key of an unpacked field
Description
Update the key of an unpacked field
Usage
.unpack_key(field, key)
Arguments
field |
( |
key |
( |
Value
(tib_collector) The field with updated key.
Untibblify a data frame into a list of row lists
Description
Untibblify a data frame into a list of row lists
Usage
.untibblify_df(x, spec, call = caller_env())
Arguments
x |
( |
spec |
( |
call |
( |
Value
A list with one named list per row of x.
Untibblify a named list using a spec
Description
Untibblify a named list using a spec
Usage
.untibblify_list(x, spec, call = caller_env())
Arguments
x |
( |
spec |
( |
call |
( |
Value
A named list with fields converted according to spec.
Untibblify a single list element
Description
Untibblify a single list element
Usage
.untibblify_list_elt(x, field_spec, call = caller_env())
Arguments
x |
( |
field_spec |
( |
call |
( |
Value
The converted element, or x unchanged if no conversion applies.
Untibblify a single data frame row into a named list
Description
Untibblify a single data frame row into a named list
Usage
.untibblify_row(x, spec, call = caller_env())
Arguments
x |
( |
spec |
( |
call |
( |
Value
A named list with one element per field of x.
Update the required status of field specs
Description
Update the required status of field specs
Usage
.update_required_fields(fields, required)
Arguments
fields |
( |
required |
( |
Value
fields with the $required component of each spec updated.
Flatten a list to a vector
Description
Flatten a list to a vector
Usage
.vec_flatten(x, ptype, name_spec = zap())
Arguments
x |
( |
ptype |
( |
name_spec |
( |
Value
A vector with elements from x.
Convert a vector column to a tib scalar or unspecified specification
Description
Convert a vector column to a tib scalar or unspecified specification
Usage
.vector_col_to_spec(col, name)
Arguments
col |
( |
name |
( |
Value
A tib_scalar() or tib_unspecified() specification.
Walk the tree level by level, collecting a snapshot at each depth
Description
Walk the tree level by level, collecting a snapshot at each depth
Usage
.walk_tree_levels(x, id_col, child_col, call)
Arguments
x |
( |
id_col |
( |
child_col |
( |
call |
( |
Value
A list of per-level snapshots, each with elements data, ns,
parent_ids, and child_sizes.
Wrap indexed purrr errors with context
Description
Wrap indexed purrr errors with context
Usage
.with_indexed_errors(
expr,
message,
error_call = caller_env(),
env = caller_env()
)
Arguments
expr |
( |
message |
( |
error_call |
( |
env |
( |
Value
The evaluated result of expr, or an error with added context.
Printing tibblify specifications
Description
The print() and format() methods for tibblify specifications provide the
code necessary to generate the specification. Function names are color-coded
to help visually distinguish different types of collectors.
Usage
## S3 method for class 'tib_collector'
print(x, width = NULL, ..., names = NULL)
## S3 method for class 'tib_scalar'
format(
x,
...,
.fill = NULL,
.ptype_inner = NULL,
.transform = NULL,
multi_line = FALSE,
nchar_indent = 0,
width = NULL,
names = FALSE
)
## S3 method for class 'tib_variant'
format(x, ..., multi_line = FALSE, nchar_indent = 0, width = NULL)
## S3 method for class 'tib_vector'
format(x, ..., multi_line = FALSE, nchar_indent = 0, width = NULL)
## S3 method for class 'tib_unspecified'
format(
x,
...,
.fill = NULL,
.ptype_inner = NULL,
.transform = NULL,
multi_line = FALSE,
nchar_indent = 0,
width = NULL,
names = FALSE
)
## S3 method for class 'tib_scalar_chr_date'
format(x, ..., multi_line = FALSE, nchar_indent = 0, width = NULL)
## S3 method for class 'tib_vector_chr_date'
format(x, ..., multi_line = FALSE, nchar_indent = 0, width = NULL)
## S3 method for class 'tib_row'
format(x, ..., width = NULL, names = NULL)
## S3 method for class 'tib_df'
format(x, ..., width = NULL, names = NULL)
## S3 method for class 'tib_recursive'
format(x, ..., width = NULL, names = NULL)
## S3 method for class 'tibblify_object'
print(x, ...)
## S3 method for class 'tspec'
print(x, width = NULL, ..., names = NULL)
## S3 method for class 'tspec_df'
format(x, width = NULL, ..., names = NULL)
## S3 method for class 'tspec_row'
format(x, width = NULL, ..., names = NULL)
## S3 method for class 'tspec_recursive'
format(x, width = NULL, ..., names = NULL)
## S3 method for class 'tspec_object'
format(x, width = NULL, ..., names = NULL)
Arguments
x |
( |
width |
( |
... |
These dots are for future extensions and must be empty. |
names |
( |
.fill |
( |
.ptype_inner |
( |
.transform |
( |
multi_line |
( |
nchar_indent |
( |
Value
For print() methods, x is returned invisibly. format() methods
return a length-1 character vector.
Examples
spec <- tspec_df(
a = tib_int("a"),
new_name = tib_chr("b"),
row = tib_row(
"row",
x = tib_int("x")
)
)
print(spec, names = FALSE)
print(spec, names = TRUE)
Examine the column specification
Description
Examine the column specification
Usage
get_spec(x)
Arguments
x |
( |
Value
A tibblify specification as returned by tspec_df(), tspec_row(),
tspec_object(), or tspec_recursive().
Examples
df <- tibblify(list(list(x = 1, y = "a"), list(x = 2)))
get_spec(df)
Guess the tibblify() specification
Description
guess_tspec() automatically dispatches to the other guess_tspec_*()
functions based on the shape of the input. If you are unhappy with its
output, calling a specific guess_tspec_*() function may yield better
results, or at least clearer error messages about why that type isn't
supported.
Use
guess_tspec_df()if the input is a data frame.Use
guess_tspec_object()if the input is an object (such as a JSON object that has been read into R as a named list).Use
guess_tspec_object_list()if the input is a list of objects (such as a JSON object that has been read into R as a list of named lists).Use
guess_tspec_list()if the input object is a list but you aren't sure how it should be processed.
See vignette("supported-structures") for a discussion of the input types
supported by tibblify.
Usage
guess_tspec(
x,
...,
empty_list_unspecified = FALSE,
simplify_list = FALSE,
inform_unspecified = should_inform_unspecified(),
call = rlang::caller_env()
)
guess_tspec_df(
x,
...,
empty_list_unspecified = FALSE,
simplify_list = FALSE,
inform_unspecified = should_inform_unspecified(),
call = rlang::current_call(),
arg = rlang::caller_arg(x)
)
guess_tspec_list(
x,
...,
empty_list_unspecified = FALSE,
simplify_list = FALSE,
inform_unspecified = should_inform_unspecified(),
arg = caller_arg(x),
call = current_call()
)
guess_tspec_object(
x,
...,
empty_list_unspecified = FALSE,
simplify_list = FALSE,
inform_unspecified = should_inform_unspecified(),
call = rlang::current_call()
)
guess_tspec_object_list(
x,
...,
empty_list_unspecified = FALSE,
simplify_list = FALSE,
inform_unspecified = should_inform_unspecified(),
arg = caller_arg(x),
call = current_call()
)
Arguments
x |
( |
... |
These dots are for future extensions and must be empty. |
empty_list_unspecified |
( |
simplify_list |
( |
inform_unspecified |
( |
call |
( |
arg |
( |
Value
A specification object that can be used in tibblify().
Examples
guess_tspec(list(x = 1, y = "a"))
guess_tspec(list(list(x = 1), list(x = 2)))
Convert a data frame to a tree
Description
Recursively nest data frame rows based on parent-child relationships, defined by an id column and a parent column. Children become sub-tibbles of their parent rows. This structure is intended for representing tree-like data, such as organizational charts, file systems, category trees, or any other hierarchical relationships.
Usage
nest_tree(x, id_col, parent_col, children_to)
Arguments
x |
( |
id_col |
( |
parent_col |
( |
children_to |
( |
Value
A tree-like, recursively nested data frame.
Examples
df <- tibble::tibble(
id = 1:5,
x = letters[1:5],
parent = c(NA, NA, 1L, 2L, 4L)
)
df
# Only the root elements are in the top-level tibble.
out <- nest_tree(df, id, parent, "children")
out
# The children of each element are stored in the "children" column.
out$children
# "d" (id 4) is a child of "b" (id 2), and "e" (id 5) is a child of "d"
# (id 4).
out$children[[2]]$children
Parse an OpenAPI spec
Description
The OpenAPI Initiative is a Linux Foundation project to define an
OpenAPI Specification, a formal
standard for describing HTTP APIs. Use parse_openapi_spec() to parse such
OpenAPI specs. You can also parse OpenAPI Schema Objects (which
describe the structure of input and output datatypes) directly with
parse_openapi_schema().
Usage
parse_openapi_spec(file)
parse_openapi_schema(file)
Arguments
file |
( |
Value
For parse_openapi_spec(), a nested data frame with the columns
-
endpoint(character) Name of the endpoint. -
operations(list) A list of data frames describing that endpoint. See the Paths Object in the OpenAPI spec for details. All references ($ref) in the spec are resolved.
For parse_openapi_schema(), a tibblify spec. All references ($ref) in
the spec are resolved.
Shortcomings
This implementation is not complete, and there are some known shortcomings:
We only tibblify the
pathspart of the spec, although we also parse thecomponentspart in order to resolve references.We do not yet support
summaryordescriptionfields in path item objects.We do not yet incorporate
parametersdefined at the path item level into operation-level parameter parsing. We do, however, parse and include them in theglobal_parameterscolumn of the operations tibble, so they are available even though they are not yet merged into each operation's parameters.We do not yet support
linksin response objects.We do not yet support
callbacksin operation objects.We do not yet support OpenAPI extensions (fields starting with
x-).Our implementation of
oneOf,anyOf, andallOfis very basic and may not cover all cases.
Examples
file <- '{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "Starship",
"description": "A vehicle.",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of this vehicle. The common name, e.g. Sand Crawler."
},
"model": {
"type": "string",
"description": "The model or official name of this vehicle."
},
"url": {
"type": "string",
"format": "uri",
"description": "The hypermedia URL of this resource."
},
"edited": {
"type": "string",
"format": "date-time",
"description": "the ISO 8601 date format of the time this resource was edited."
}
},
"required": [
"name",
"model",
"edited"
]
}'
parse_openapi_schema(file)
# Spec example from
# https://swagger.io/docs/specification/v3_0/basic-structure/
spec_path <- system.file(
"examples", "openapi", "sample_api.yaml", package = "tibblify"
)
spec <- parse_openapi_spec(spec_path)
spec
Politicians
Description
A dataset containing some basic information about some politicians.
Usage
politicians
Format
A list of lists.
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
Determine whether to inform about unspecified fields in spec
Description
Wrapper around getOption("tibblify.show_unspecified") to return TRUE
unless the option is explicitly set to FALSE.
Usage
should_inform_unspecified()
Value
FALSE if the option is set to FALSE, TRUE otherwise.
Examples
should_inform_unspecified()
Create a field specification
Description
Use the tib_*() functions to specify how to process the fields of an
object.
Usage
tib_scalar(
.key,
.ptype,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = .ptype,
.transform = NULL,
key = deprecated(),
ptype = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated()
)
tib_vector(
.key,
.ptype,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = .ptype,
.transform = NULL,
.elt_transform = NULL,
.input_form = c("vector", "scalar_list", "object"),
.values_to = NULL,
.names_to = NULL,
key = deprecated(),
ptype = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated(),
elt_transform = deprecated(),
input_form = deprecated(),
values_to = deprecated(),
names_to = deprecated()
)
tib_unspecified(
.key,
...,
.required = TRUE,
key = deprecated(),
required = deprecated()
)
tib_lgl(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = logical(),
.transform = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated()
)
tib_int(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = integer(),
.transform = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated()
)
tib_dbl(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = double(),
.transform = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated()
)
tib_chr(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = character(),
.transform = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated()
)
tib_date(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = vctrs::new_date(),
.transform = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated()
)
tib_chr_date(
.key,
...,
.required = TRUE,
.fill = NULL,
.format = "%Y-%m-%d",
key = deprecated(),
required = deprecated(),
fill = deprecated(),
format = deprecated()
)
tib_lgl_vec(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = logical(),
.transform = NULL,
.elt_transform = NULL,
.input_form = c("vector", "scalar_list", "object"),
.values_to = NULL,
.names_to = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated(),
elt_transform = deprecated(),
input_form = deprecated(),
values_to = deprecated(),
names_to = deprecated()
)
tib_int_vec(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = integer(),
.transform = NULL,
.elt_transform = NULL,
.input_form = c("vector", "scalar_list", "object"),
.values_to = NULL,
.names_to = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated(),
elt_transform = deprecated(),
input_form = deprecated(),
values_to = deprecated(),
names_to = deprecated()
)
tib_dbl_vec(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = double(),
.transform = NULL,
.elt_transform = NULL,
.input_form = c("vector", "scalar_list", "object"),
.values_to = NULL,
.names_to = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated(),
elt_transform = deprecated(),
input_form = deprecated(),
values_to = deprecated(),
names_to = deprecated()
)
tib_chr_vec(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = character(),
.transform = NULL,
.elt_transform = NULL,
.input_form = c("vector", "scalar_list", "object"),
.values_to = NULL,
.names_to = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated(),
elt_transform = deprecated(),
input_form = deprecated(),
values_to = deprecated(),
names_to = deprecated()
)
tib_date_vec(
.key,
...,
.required = TRUE,
.fill = NULL,
.ptype_inner = vctrs::new_date(),
.transform = NULL,
.elt_transform = NULL,
.input_form = c("vector", "scalar_list", "object"),
.values_to = NULL,
.names_to = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
ptype_inner = deprecated(),
transform = deprecated(),
elt_transform = deprecated(),
input_form = deprecated(),
values_to = deprecated(),
names_to = deprecated()
)
tib_chr_date_vec(
.key,
...,
.required = TRUE,
.fill = NULL,
.input_form = c("vector", "scalar_list", "object"),
.values_to = NULL,
.names_to = NULL,
.format = "%Y-%m-%d",
key = deprecated(),
required = deprecated(),
fill = deprecated(),
input_form = deprecated(),
values_to = deprecated(),
names_to = deprecated(),
format = deprecated()
)
tib_variant(
.key,
...,
.required = TRUE,
.fill = NULL,
.transform = NULL,
.elt_transform = NULL,
key = deprecated(),
required = deprecated(),
fill = deprecated(),
transform = deprecated(),
elt_transform = deprecated()
)
tib_recursive(.key, ..., .children, .children_to = .children, .required = TRUE)
tib_row(.key, ..., .required = TRUE)
tib_df(.key, ..., .required = TRUE, .names_to = NULL)
Arguments
.key, key |
( |
.ptype, ptype |
( |
... |
These dots are for future extensions and must be empty. |
.required, required |
( |
.fill, fill |
( |
.ptype_inner, ptype_inner |
( |
.transform, transform |
( |
.elt_transform, elt_transform |
( |
.input_form, input_form |
(
|
.values_to, values_to |
( |
.names_to, names_to |
(
|
.format, format |
( |
.children |
( |
.children_to |
( |
Details
There are five families of tib_*() functions:
-
tib_scalar(.ptype): Cast each instance of the field to a length-one vector of type.ptype. Insidetspec_df(), this results in a column of the specified.ptype. -
tib_vector(.ptype): Cast each instance of the field to an arbitrary length vector of type.ptype. Insidetspec_df(), this results in a list column of vectors of the specified.ptype. -
tib_variant(): Cast each instance of the field to a list. Insidetspec_df(), this results in a list column of lists. -
tib_row(): Cast each instance of the field to a 1-row tibble. Insidetspec_df(), this results in a list column of 1-row tibbles. -
tib_df(): Cast each instance of the field to a tibble. Insidetspec_df(), this results in a list column of tibbles (each of which can have multiple rows).There are some special shortcuts of
tib_scalar()andtib_vector()for the most common prototypes: -
logical():tib_lgl()andtib_lgl_vec() -
integer():tib_int()andtib_int_vec() -
double():tib_dbl()andtib_dbl_vec() -
character():tib_chr()andtib_chr_vec() -
Date:tib_date()andtib_date_vec()Further, there are special shortcuts for dates encoded as character:
tib_chr_date()andtib_chr_date_vec().There are two other
tib_*()functions for special cases: -
tib_recursive(): Cast each instance of the field to a tibble, within which columns can themselves contain the same sorts of tibble, etc. Insidetspec_df(), this results in a list column of tibbles, each row of which can itself contain a tibble, etc. This is intended for structures such as a directory tree. -
tib_unspecified(): Tag a field in the object as unspecified. Theunspecifiedargument oftibblify()controls how such fields are handled. If you are constructing a specification manually (as opposed to usingguess_tspec()), you should most likely specify such columns withtib_variant(), or leave them out of the spec entirely.
Value
A tibblify field collector. This specification can be used with
tspec_df() or another tspec_*() function to specify how to process an
object.
Examples
tib_int("int")
tib_int("int", .required = FALSE, .fill = 0)
# This is essentially how `tib_chr_date()` is implemented.
tib_scalar(
"date",
Sys.Date(),
.transform = function(x) as.Date(x, format = "%Y-%m-%d")
)
tib_df(
"data",
.names_to = "id",
age = tib_int("age"),
name = tib_chr("name")
)
Rectangle a nested list
Description
Transform a nested list into a tibble or a list of objects according to a specification.
Usage
tibblify(x, spec = NULL, unspecified = NULL)
Arguments
x |
( |
spec |
( |
unspecified |
(
|
Details
Fields specifically tagged as tib_unspecified() in the spec (or guessed
as such) will be handled according to the unspecified argument. Fields that
are present in x but not mentioned in the spec are ignored.
Value
Either a tibble or a list, depending on the specification.
See Also
Use untibblify() to undo the result of tibblify().
Examples
# List of Objects -----------------------------------------------------------
x <- list(
list(id = 1, name = "Tyrion Lannister"),
list(id = 2, name = "Victarion Greyjoy")
)
tibblify(x)
# Provide a specification
spec <- tspec_df(
id = tib_int("id"),
name = tib_chr("name")
)
tibblify(x, spec)
# Object --------------------------------------------------------------------
# Provide a specification for a single object
tibblify(x[[1]], tspec_object(spec))
# Recursive Trees -----------------------------------------------------------
x <- list(
list(
id = 1,
name = "a",
children = list(
list(id = 11, name = "aa"),
list(id = 12, name = "ab", children = list(
list(id = 121, name = "aba")
))
))
)
spec <- tspec_recursive(
tib_int("id"),
tib_chr("name"),
.children = "children"
)
out <- tibblify(x, spec)
out
out$children
out$children[[1]]$children[[2]]
Combine multiple specifications
Description
Combine specifications created by tspec_df(), tspec_row(), or
tspec_object(). The resulting specification includes all fields from the
input specifications.
Usage
tspec_combine(...)
Arguments
... |
( |
Details
If a field is specified in multiple input specifications, the field specifications will be combined to produce a single field specification, using the most specific specification for each argument. See the examples for details.
Value
A tibblify specification.
Examples
# union of fields
tspec_combine(
tspec_df(tib_int("a")),
tspec_df(tib_chr("b"))
)
# unspecified + x -> x
tspec_combine(
tspec_df(tib_unspecified("a")),
tspec_df(tib_int("a"))
)
# scalar + vector -> vector
tspec_combine(
tspec_df(tib_chr("a")),
tspec_df(tib_chr_vec("a"))
)
# scalar/vector + variant -> variant
tspec_combine(
tspec_df(tib_chr("a")),
tspec_df(tib_chr_vec("a")),
tspec_df(tib_variant("a"))
)
Create a tibblify specification
Description
Use tspec_df() to specify how to convert a list of objects to a tibble. Use
tspec_row() to specify how to convert an object to a one-row tibble. Use
tspec_object() to specify how to convert an object to a list.
Usage
tspec_df(
...,
.input_form = c("rowmajor", "colmajor"),
.names_to = NULL,
.vector_allows_empty_list = FALSE,
vector_allows_empty_list = deprecated()
)
tspec_object(
...,
.input_form = c("rowmajor", "colmajor"),
.vector_allows_empty_list = FALSE,
vector_allows_empty_list = deprecated()
)
tspec_row(
...,
.input_form = c("rowmajor", "colmajor"),
.vector_allows_empty_list = FALSE,
vector_allows_empty_list = deprecated()
)
tspec_recursive(
...,
.children,
.children_to = .children,
.input_form = c("rowmajor", "colmajor"),
.vector_allows_empty_list = FALSE,
vector_allows_empty_list = deprecated()
)
Arguments
... |
( |
.input_form |
(
|
.names_to |
( |
.vector_allows_empty_list, vector_allows_empty_list |
( |
.children |
( |
.children_to |
( |
Details
In column-major format, all fields are required, regardless of the
.required argument.
Value
A tibblify specification.
Examples
tspec_df(
id = tib_int("id"),
name = tib_chr("name"),
aliases = tib_chr_vec("aliases")
)
# Equivalent to
tspec_df(
tib_int("id"),
tib_chr("name"),
tib_chr_vec("aliases")
)
# To create multiple columns of the same type use the bang-bang-bang (`!!!`)
# operator together with `purrr::map()`
tspec_df(
!!!purrr::map(rlang::set_names(c("id", "age")), tib_int),
!!!purrr::map(rlang::set_names(c("name", "title")), tib_chr)
)
# The `tspec_*()` functions can also be nested
spec1 <- tspec_object(
int = tib_int("int"),
chr = tib_chr("chr")
)
spec2 <- tspec_object(
int2 = tib_int("int2"),
chr2 = tib_chr("chr2")
)
tspec_df(spec1, spec2)
Unnest a recursive data frame
Description
Unnest a recursive data frame
Usage
unnest_tree(
x,
id_col,
child_col,
level_to = "level",
parent_to = "parent",
ancestors_to = NULL
)
Arguments
x |
( |
id_col |
( |
child_col |
( |
level_to |
( |
parent_to |
( |
ancestors_to |
( |
Value
A "flat" data frame.
Examples
df <- tibble(
id = 1L,
name = "a",
children = list(
tibble(
id = 11:12,
name = c("b", "c"),
children = list(
NULL,
tibble(
id = 121:122,
name = c("d", "e")
)
)
)
)
)
df
unnest_tree(
df,
id_col = "id",
child_col = "children",
level_to = "level",
parent_to = "parent",
ancestors_to = "ancestors"
)
Unpack a tibblify specification
Description
tidyr::unpack() makes data wider by expanding df-columns into individual
columns. Analogously, unpacking a tibblify specification makes a
specification which will result in a wider tibble by expanding tib_row()
specifications into their individual fields.
Usage
unpack_tspec(
spec,
...,
fields = NULL,
recurse = TRUE,
names_sep = NULL,
names_repair = c("unique", "universal", "check_unique", "unique_quiet",
"universal_quiet"),
names_clean = NULL
)
camel_case_to_snake_case(x)
Arguments
spec |
( |
... |
These dots are for future extensions and must be empty. |
fields |
( |
recurse |
( |
names_sep |
( |
names_repair |
(
|
names_clean |
( |
x |
( |
Value
A tibblify spec.
Examples
spec <- tspec_df(
tib_lgl("a"),
tib_row("x", tib_int("b"), tib_chr("c")),
tib_row("y", tib_row("z", tib_chr("d")))
)
unpack_tspec(spec)
# only unpack `x`
unpack_tspec(spec, fields = "x")
# do not unpack the fields in `y`
unpack_tspec(spec, recurse = FALSE)
camel_case_to_snake_case(c("ExampleText", "otherTextToConvert"))
Convert a data frame or object into a nested list
Description
Convert a data frame or an object into a nested list. This is the inverse
operation of tibblify(). See vignette("supported-structures") for a
description of objects recognized by tibblify.
Usage
untibblify(x, spec = get_spec(x))
Arguments
x |
( |
spec |
( |
Value
A nested list.
Examples
x <- tibble(
a = 1:2,
b = tibble(
x = c("a", "b"),
y = c(1.5, 2.5)
)
)
untibblify(x)