# NOT RUN {
# Create pillar objects
ctl_new_pillar(
palmerpenguins::penguins,
palmerpenguins::penguins$species[1:3], width = 60
)
ctl_new_pillar(
palmerpenguins::penguins,
palmerpenguins::penguins$bill_length_mm[1:3],
width = 60
)
# Packed data frame
ctl_new_compound_pillar(
tibble::tibble(),
palmerpenguins::penguins,
width = 60
)
# Packed matrix
ctl_new_compound_pillar(tibble::tibble(), matrix(1:6, ncol = 2), width = 60)
# Packed array
ctl_new_compound_pillar(tibble::tibble(), Titanic, width = 60)
# }
# NOT RUN {
# Customize output
lines <- function(char = "-") {
stopifnot(nchar(char) == 1)
structure(char, class = "lines")
}
format.lines <- function(x, width, ...) {
paste(rep(x, width), collapse = "")
}
ctl_new_pillar.line_tbl <- function(controller, x, width, ..., title = NULL) {
out <- NextMethod()
new_pillar(list(
title = out$title,
type = out$type,
lines = new_pillar_component(list(lines("=")), width = 1),
data = out$data
))
}
vctrs::new_data_frame(
list(a = 1:3, b = letters[1:3]),
class = c("line_tbl", "tbl")
)
# }
Run the code above in your browser using DataLab