gt_preview {gt} | R Documentation |
Generate a special gt table for previewing a dataset
Description
Sometimes you may want to see just a small portion of your input data. We can
use gt_preview()
in place of gt()
to get the first x rows of data and the
last y rows of data (which can be set by the top_n
and bottom_n
arguments). It's not advised to use additional gt functions to further
modify the output of gt_preview()
. Furthermore, you cannot pass a gt
object to gt_preview()
.
Usage
gt_preview(data, top_n = 5, bottom_n = 1, incl_rownums = TRUE)
Arguments
data |
Input data table
A |
top_n |
Top n rows to display
The |
bottom_n |
Bottom n rows to display
The |
incl_rownums |
Display row numbers
An option to include the row numbers for |
Details
By default, the output table will include row numbers in a stub (including a
range of row numbers for the omitted rows). This row numbering option can be
deactivated by setting incl_rownums
to FALSE
.
Value
An object of class gt_tbl
.
Examples
With three columns from the gtcars
dataset, let's create a gt table
preview with the gt_preview()
function. You'll get only the first five rows
and the last row.
gtcars |> dplyr::select(mfr, model, year) |> gt_preview()
![This image of a table was generated from the first code example in the `gt_preview()` help file.](https://raw.githubusercontent.com/rstudio/gt/master/images/man_gt_preview_1.png)
Function ID
1-2
Function Introduced
v0.2.0.5
(March 31, 2020)
See Also
Other table creation functions:
gt()