A gt display table render function for use in ShinySource:
render_gt() we can create a reactive gt table that works
wonderfully once assigned to an output slot (with
function is to be used within Shiny's
server() component. We have some
options for controlling the size of the container holding the gt table.
height arguments allow for sizing the container, and the
align argument allows us to align the table within the container (some
other fine-grained options for positioning are available in the
An expression that creates a gt table object. For sake of convenience, a data frame or tibble can be used here (it will be automatically introduced to
gt()with its default options).
- width, height
The width and height of the table's container. Either can be specified as a single-length character with units of pixels or as a percentage. If provided as a single-length numeric vector, it is assumed that the value is given in units of pixels. The
pct()helper functions can also be used to pass in numeric values and obtain values as pixel or percent units.
The alignment of the table in its container. By default, this is
"center". Other options are
The environment in which to evaluate the
expra quoted expression (with
quote())? This is useful if you want to save an expression in a variable.
A list of arguments to be passed through to the implicit call to
render_gtis used in an interactive R Markdown document.
We need to ensure that we have the shiny package installed first. This
is easily by using
install.packages("shiny"). More information on creating
Shiny apps can be found at the Shiny Site.
Here is a Shiny app (contained within a single file) that (1) prepares a
gt table, (2) sets up the
gt_output(), and (3) sets up the
server with a
render_gt() that uses the
gt_tbl object as the input
Other Shiny functions: