1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tbl-format-setup.R
\name{tbl_format_setup}
\alias{tbl_format_setup}
\alias{tbl_format_setup.tbl}
\title{Set up formatting}
\usage{
tbl_format_setup(
x,
width = NULL,
...,
n = NULL,
max_extra_cols = NULL,
max_footer_lines = NULL,
focus = NULL
)
\method{tbl_format_setup}{tbl}(x, width, ..., n, max_extra_cols, max_footer_lines, focus)
}
\arguments{
\item{x}{An object.}
\item{width}{Actual width for printing, a numeric greater than zero.
This argument is mandatory for all implementations of this method.}
\item{...}{Extra arguments to \code{\link[=print.tbl]{print.tbl()}} or \code{\link[=format.tbl]{format.tbl()}}.}
\item{n}{Actual number of rows to print.
No \link[=pillar_options]{options} should be considered
by implementations of this method.}
\item{max_extra_cols}{Number of columns to print abbreviated information for,
if the width is too small for the entire tibble.
No \link[=pillar_options]{options} should be considered
by implementations of this method.}
\item{max_footer_lines}{Maximum number of lines for the footer.
No \link[=pillar_options]{options} should be considered
by implementations of this method.}
\item{focus}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
Names of columns to show preferentially if space is tight.}
}
\value{
An object that can be passed as \code{setup} argument to
\code{\link[=tbl_format_header]{tbl_format_header()}}, \code{\link[=tbl_format_body]{tbl_format_body()}}, and \code{\link[=tbl_format_footer]{tbl_format_footer()}}.
}
\description{
\code{tbl_format_setup()} is called by \code{\link[=format.tbl]{format.tbl()}}.
This method collects information that is common to the header, body,
and footer parts of a tibble.
Examples:
\itemize{
\item the dimensions sometimes are reported both in the header
and (implicitly) in the footer of a tibble;
\item the columns shown in the body decide which columns are shown in the footer.
}
This information is computed once in \code{tbl_format_setup()}.
The result is passed on to the
\code{\link[=tbl_format_header]{tbl_format_header()}}, \code{\link[=tbl_format_body]{tbl_format_body()}}, and \code{\link[=tbl_format_footer]{tbl_format_footer()}}
methods.
If you need to customize parts of the printed output independently,
override these methods instead.
}
\details{
Extend this method to prepare information that is used
in several parts of the printed output of a tibble-like object,
or to collect additional arguments passed via \code{...} to
\code{\link[=print.tbl]{print.tbl()}} or \code{\link[=format.tbl]{format.tbl()}}.
We expect that \code{tbl_format_setup()} is extended only rarely,
and overridden only in exceptional circumstances, if at all.
If you override this method, you must also implement
\code{\link[=tbl_format_header]{tbl_format_header()}}, \code{\link[=tbl_format_body]{tbl_format_body()}}, and \code{\link[=tbl_format_footer]{tbl_format_footer()}}
for your class.
Implementing a method
allows to override printing and formatting of the entire object
without overriding the \code{\link[=print]{print()}} and \code{\link[=format]{format()}} methods directly.
This allows to keep the logic of the \code{width} and \code{n} arguments.
The default method for the \code{"tbl"} class collects information for
standard printing for tibbles.
See \code{\link[=new_tbl_format_setup]{new_tbl_format_setup()}} for details on the returned object.
}
\examples{
\dontshow{if (rlang::is_installed("palmerpenguins")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
tbl_format_setup(palmerpenguins::penguins)
\dontshow{\}) # examplesIf}
}
|