tspec_df(
id = tib_int("id"),
name = tib_chr("name"),
aliases = 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(purrr::set_names(c("id", "age")), tib_int),
!!!purrr::map(purrr::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)
Run the code above in your browser using DataLab