EVOLUTION-MANAGER
Edit File: char.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: Format a character vector</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 char {tibble}"><tr><td>char {tibble}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Format a character vector</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>Constructs a character vector that can be formatted with predefined minimum width or without width restrictions, and where the abbreviation style can be configured. </p> <p>The formatting is applied when the vector is printed or formatted, and also in a tibble column. </p> <p><code>set_char_opts()</code> adds formatting options to an arbitrary character vector, useful for composing with other types. </p> <h3>Usage</h3> <pre> char( x, ..., min_chars = NULL, shorten = c("back", "front", "mid", "abbreviate") ) set_char_opts( x, ..., min_chars = NULL, shorten = c("back", "front", "mid", "abbreviate") ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A character vector.</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>min_chars</code></td> <td> <p>The minimum width to allocate to this column, defaults to 15. The <code>"pillar.min_chars"</code> <a href="../../pillar/html/pillar_options.html">option</a> is not consulted.</p> </td></tr> <tr valign="top"><td><code>shorten</code></td> <td> <p>How to abbreviate the data if necessary: </p> <ul> <li> <p><code>"back"</code> (default): add an ellipsis at the end </p> </li> <li> <p><code>"front"</code>: add an ellipsis at the front </p> </li> <li> <p><code>"mid"</code>: add an ellipsis in the middle </p> </li> <li> <p><code>"abbreviate"</code>: use <code><a href="../../base/html/abbreviate.html">abbreviate()</a></code> </p> </li></ul> </td></tr> </table> <h3>See Also</h3> <p>Other vector classes: <code><a href="num.html">num</a>()</code> </p> <h3>Examples</h3> <pre> # Display as a vector: char(letters[1:3]) # Space constraints: rand_strings <- stringi::stri_rand_strings(10, seq(40, 22, by = -2)) # Plain character vectors get truncated if space is limited: data_with_id <- function(id) { tibble( id, some_number_1 = 1, some_number_2 = 2, some_number_3 = 3, some_number_4 = 4, some_number_5 = 5, some_number_6 = 6, some_number_7 = 7, some_number_8 = 8, some_number_9 = 9 ) } data_with_id(rand_strings) # Use char() to avoid or control truncation data_with_id(char(rand_strings, min_chars = 24)) data_with_id(char(rand_strings, min_chars = Inf)) data_with_id(char(rand_strings, min_chars = 24, shorten = "mid")) # Lorem Ipsum, one sentence per row. lipsum <- unlist(strsplit(stringi::stri_rand_lipsum(1), "(?<=[.]) +", perl = TRUE)) tibble( back = char(lipsum, shorten = "back"), front = char(lipsum, shorten = "front"), mid = char(lipsum, shorten = "mid") ) tibble(abbr = char(lipsum, shorten = "abbreviate")) </pre> <hr /><div style="text-align: center;">[Package <em>tibble</em> version 3.1.8 <a href="00Index.html">Index</a>]</div> </body></html>