| tib_spec | R Documentation |
Use the tib_*() functions to specify how to process the fields of an
object.
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)
.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 |
( |
There are five families of tib_*() functions:
tib_scalar(.ptype): Cast each instance of the field to a length-one
vector of type .ptype. Inside tspec_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. Inside tspec_df(), this results in a list
column of vectors of the specified .ptype.
tib_variant(): Cast each instance of the field to a list. Inside
tspec_df(), this results in a list column of lists.
tib_row(): Cast each instance of the field to a 1-row tibble. Inside
tspec_df(), this results in a list column of 1-row tibbles.
tib_df(): Cast each instance of the field to a tibble. Inside
tspec_df(), this results in a list column of tibbles (each of which can
have multiple rows).
There are some special shortcuts of tib_scalar() and tib_vector() for
the most common prototypes:
logical(): tib_lgl() and tib_lgl_vec()
integer(): tib_int() and tib_int_vec()
double(): tib_dbl() and tib_dbl_vec()
character(): tib_chr() and tib_chr_vec()
Date: tib_date() and tib_date_vec()
Further, there are special shortcuts for dates encoded as character:
tib_chr_date() and tib_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. Inside
tspec_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. The
unspecified argument of tibblify() controls how such fields are
handled. If you are constructing a specification manually (as opposed to
using guess_tspec()), you should most likely specify such columns with
tib_variant(), or leave them out of the spec entirely.
A tibblify field collector. This specification can be used with
tspec_df() or another tspec_*() function to specify how to process an
object.
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")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.