EVOLUTION-MANAGER
Edit File: ctl_new_pillar.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Customize the appearance of simple pillars in your tibble...</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for ctl_new_pillar {pillar}"><tr><td>ctl_new_pillar {pillar}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Customize the appearance of simple pillars in your tibble subclass</h2> <h3>Description</h3> <p><a href="https://lifecycle.r-lib.org/articles/stages.html#experimental"><img src="../help/figures/lifecycle-experimental.svg" alt='[Experimental]' /></a> </p> <p>Gain full control over the appearance of the pillars of your tibble subclass in its body. This method is intended for implementers of subclasses of the <code>"tbl"</code> class. Users will rarely need them. </p> <h3>Usage</h3> <pre> ctl_new_pillar(controller, x, width, ..., title = NULL) ctl_new_rowid_pillar(controller, x, width, ..., title = NULL, type = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>controller</code></td> <td> <p>The object of class <code>"tbl"</code> currently printed.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>A simple (one-dimensional) vector.</p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>The available width, can be a vector for multiple tiers.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>These dots are for future extensions and must be empty.</p> </td></tr> <tr valign="top"><td><code>title</code></td> <td> <p>The title, derived from the name of the column in the data.</p> </td></tr> <tr valign="top"><td><code>type</code></td> <td> <p>String for specifying a row ID type. Current values in use are <code>NULL</code> and <code>"*"</code>.</p> </td></tr> </table> <h3>Details</h3> <p><code>ctl_new_pillar()</code> is called to construct pillars for regular (one-dimensional) vectors. The default implementation returns an object constructed with <code><a href="pillar.html">pillar()</a></code>. Extend this method to modify the pillar components returned from the default implementation. Override this method to completely change the appearance of the pillars. Components are created with <code><a href="new_pillar_component.html">new_pillar_component()</a></code> or <code><a href="new_pillar_component.html">pillar_component()</a></code>. In order to customize printing of row IDs, a method can be supplied for the <code>ctl_new_rowid_pillar()</code> generic. </p> <p>All components must be of the same height. This restriction may be levied in the future. </p> <p>Implementations should return <code>NULL</code> if none of the data fits the available width. </p> <h3>See Also</h3> <p>See <code><a href="ctl_new_pillar_list.html">ctl_new_pillar_list()</a></code> for creating pillar objects for compound columns: packed data frames, matrices, or arrays. </p> <h3>Examples</h3> <pre> # 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 ) # 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, ...) { out <- NextMethod() new_pillar(list( title = out$title, type = out$type, lines = new_pillar_component(list(lines("=")), width = 1), data = out$data )) } ctl_new_rowid_pillar.line_tbl <- function(controller, x, width, ...) { out <- NextMethod() new_pillar( list( title = out$title, type = out$type, lines = new_pillar_component(list(lines("=")), width = 1), data = out$data ), width = as.integer(floor(log10(max(nrow(x), 1))) + 1) ) } vctrs::new_data_frame( list(a = 1:3, b = letters[1:3]), class = c("line_tbl", "tbl") ) ctl_new_rowid_pillar.roman_tbl <- function(controller, x, width, ...) { out <- NextMethod() rowid <- utils::as.roman(seq_len(nrow(x))) width <- max(nchar(as.character(rowid))) new_pillar( list( title = out$title, type = out$type, data = pillar_component( new_pillar_shaft(list(row_ids = rowid), width = width, class = "pillar_rif_shaft" ) ) ), width = width ) } vctrs::new_data_frame( list(a = 1:3, b = letters[1:3]), class = c("roman_tbl", "tbl") ) </pre> <hr /><div style="text-align: center;">[Package <em>pillar</em> version 1.8.1 <a href="00Index.html">Index</a>]</div> </body></html>