formatting: Printing tibbles

Description Usage Arguments Package options Examples

Description

\lifecycle

maturing

One of the main features of the tbl_df class is the printing:

Printing can be tweaked for a one-off call by calling print() explicitly and setting arguments like n and width. More persistent control is available by setting the options described below.

Usage

1
2
3
4
5
6
7
## S3 method for class 'tbl'
print(x, ..., n = NULL, width = NULL, n_extra = NULL)

## S3 method for class 'tbl'
format(x, ..., n = NULL, width = NULL, n_extra = NULL)

trunc_mat(x, n = NULL, width = NULL, n_extra = NULL)

Arguments

x

Object to format or print.

...

Other arguments passed on to individual methods.

n

Number of rows to show. If NULL, the default, will print all rows if less than option tibble.print_max. Otherwise, will print tibble.print_min rows.

width

Width of text output to generate. This defaults to NULL, which means use getOption("tibble.width") or (if also NULL) getOption("width"); the latter displays only the columns that fit on one screen. You can also set options(tibble.width = Inf) to override this default and always print all columns.

n_extra

Number of extra columns to print abbreviated information for, if the width is too small for the entire tibble. If NULL, the default, will print information about at most tibble.max_extra_cols extra columns.

Package options

Options used by the tibble and pillar packages to format and print tbl_df objects. Used by the formatting workhorse trunc_mat() and, therefore, indirectly, by print.tbl().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
print(as_tibble(mtcars))
print(as_tibble(mtcars), n = 1)
print(as_tibble(mtcars), n = 3)

print(as_tibble(iris), n = 100)

print(mtcars, width = 10)

mtcars2 <- as_tibble(cbind(mtcars, mtcars), .name_repair = "unique")
print(mtcars2, n = 25, n_extra = 3)

trunc_mat(mtcars)

if (requireNamespace("nycflights13", quietly = TRUE)) {
  print(nycflights13::flights, n_extra = 2)
  print(nycflights13::flights, width = Inf)
}

krlmlr/tibble documentation built on Jan. 15, 2020, 7:56 a.m.