tib_unspecified | R Documentation |
Use these functions to specify how to convert the fields of an object.
tib_unspecified(key, ..., required = TRUE)
tib_scalar(
key,
ptype,
...,
required = TRUE,
fill = NULL,
ptype_inner = ptype,
transform = NULL
)
tib_lgl(
key,
...,
required = TRUE,
fill = NULL,
ptype_inner = logical(),
transform = NULL
)
tib_int(
key,
...,
required = TRUE,
fill = NULL,
ptype_inner = integer(),
transform = NULL
)
tib_dbl(
key,
...,
required = TRUE,
fill = NULL,
ptype_inner = double(),
transform = NULL
)
tib_chr(
key,
...,
required = TRUE,
fill = NULL,
ptype_inner = character(),
transform = NULL
)
tib_date(
key,
...,
required = TRUE,
fill = NULL,
ptype_inner = vctrs::new_date(),
transform = NULL
)
tib_chr_date(key, ..., required = TRUE, fill = NULL, format = "%Y-%m-%d")
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
)
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
)
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
)
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
)
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
)
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
)
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"
)
tib_variant(
key,
...,
required = TRUE,
fill = NULL,
transform = NULL,
elt_transform = NULL
)
tib_recursive(.key, ..., .children, .children_to = .children, .required = TRUE)
tib_row(.key, ..., .required = TRUE)
tib_df(.key, ..., .required = TRUE, .names_to = NULL)
key , .key |
The path to the field in the object. |
... |
These dots are for future extensions and must be empty. |
required , .required |
Throw an error if the field does not exist? |
ptype |
A prototype of the desired output type of the field. |
fill |
Optionally, a value to use if the field does not exist. |
ptype_inner |
A prototype of the field. |
transform |
A function to apply to the whole vector after casting to
|
format |
Optional, a string passed to the |
elt_transform |
A function to apply to each element before casting
to |
input_form |
A string that describes what structure the field has. Can be one of:
|
values_to |
Can be one of the following:
|
names_to |
Can be one of the following:
|
.children |
A string giving the name of field that contains the children. |
.children_to |
A string giving the column name to store the children. |
.names_to |
A string giving the name of the column which will contain
the names of elements of the object list. If |
There are basically five different tib_*()
functions
tib_scalar(ptype)
: Cast the field to a length one vector of type ptype
.
tib_vector(ptype)
: Cast the field to an arbitrary length vector of type ptype
.
tib_variant()
: Cast the field to a list.
tib_row()
: Cast the field to a named list.
tib_df()
: Cast the field to a tibble.
There are some special shortcuts of tib_scalar()
resp. tib_vector()
for
the most common prototypes
logical()
: tib_lgl()
resp. tib_lgl_vec()
integer()
: tib_int()
resp. tib_int_vec()
double()
: tib_dbl()
resp. tib_dbl_vec()
character()
: tib_chr()
resp. tib_chr_vec()
Date
: tib_date()
resp. tib_date_vec()
Further, there is also a special shortcut for dates encoded as character:
tib_chr_date()
resp. tib_chr_date_vec()
.
A tibblify field collector.
tib_int("int")
tib_int("int", required = FALSE, fill = 0)
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.