Debian Codegraph @

man/pillar.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/ctl_pillar.R
3 \name{pillar}
4 \alias{pillar}
5 \title{Object for formatting a vector suitable for tabular display}
6 \usage{
7 pillar(x, title = NULL, width = NULL, ...)
8 }
9 \arguments{
10 \item{x}{A vector to format.}
11
12 \item{title}{An optional title for the column. The title will be
13 used "as is", no quoting will be applied.}
14
15 \item{width}{Default width, optional.}
16
17 \item{...}{Passed on to \code{\link[=pillar_shaft]{pillar_shaft()}}.}
18 }
19 \description{
20 \code{pillar()} creates an object that formats a vector.
21 The output uses one row for a title (if given), one row for the type,
22 and \code{vec_size(x)} rows for the data.
23 }
24 \details{
25 A pillar consists of arbitrary components.
26 The \code{pillar()} constructor uses \code{title}, \code{type}, and \code{data}.
27 \itemize{
28 \item \code{title} via \code{\link[=new_pillar_title]{new_pillar_title()}}
29 \item \code{type} via \code{\link[=new_pillar_type]{new_pillar_type()}}, which calls \code{\link[=type_sum]{type_sum()}}
30 internally
31 \item \code{data} via \code{\link[=pillar_shaft]{pillar_shaft()}}
32 }
33
34 All components are formatted via \code{\link[=format]{format()}} when displaying the pillar.
35 A \code{width} argument is passed to each \code{format()} call.
36
37 As of pillar 1.5.0, \code{pillar()} returns \code{NULL} if the width is insufficient
38 to display the data.
39 }
40 \examples{
41 x <- 123456789 * (10^c(-1, -3, -5, NA, -8, -10))
42 pillar(x)
43 pillar(-x)
44 pillar(runif(10))
45 pillar(rcauchy(20))
46
47 # Special values are highlighted
48 pillar(c(runif(5), NA, NaN, Inf, -Inf))
49
50 # Very wide ranges will be displayed in scientific format
51 pillar(c(1e10, 1e-10), width = 20)
52 pillar(c(1e10, 1e-10))
53
54 x <- c(FALSE, NA, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE)
55 pillar(x)
56
57 x <- c("This is string is rather long", NA, "?", "Short")
58 pillar(x)
59 pillar(x, width = 30)
60 pillar(x, width = 5)
61
62 date <- as.Date("2017-05-15")
63 pillar(date + c(1, NA, 3:5))
64 pillar(as.POSIXct(date) + c(30, NA, 600, 3600, 86400))
65 }