gt_plt_dist {gtExtras} | R Documentation |
Add distribution plots into rows of a gt
table
Description
The gt_plt_dist
function takes an existing gt_tbl
object and
adds summary distribution sparklines via ggplot2
. Note that these sparklines
are limited to density, histogram, boxplot or rug/strip charts. If you're
wanting to plot more traditional sparklines, you can use gtExtras::gt_plt_sparkline()
.
Usage
gt_plt_dist(
gt_object,
column,
type = "density",
fig_dim = c(5, 30),
line_color = "black",
fill_color = "grey",
bw = NULL,
trim = FALSE,
same_limit = TRUE
)
Arguments
gt_object |
An existing gt table object of class |
column |
The column wherein the sparkline plot should replace existing data. Note that the data must be represented as a list of numeric values ahead of time. |
type |
A string indicating the type of plot to generate, accepts |
fig_dim |
A vector of two numbers indicating the height/width of the plot in mm at a DPI of 25.4, defaults to |
line_color |
Color for the line, defaults to |
fill_color |
Color for the fill of histograms/density plots, defaults to |
bw |
The bandwidth or binwidth, passed to |
trim |
A logical indicating whether to trim the values in |
same_limit |
A logical indicating that the plots will use the same axis range ( |
Value
An object of class gt_tbl
.
Examples
library(gt) gt_sparkline_tab <- mtcars %>% dplyr::group_by(cyl) %>% # must end up with list of data for each row in the input dataframe dplyr::summarize(mpg_data = list(mpg), .groups = "drop") %>% gt() %>% gt_plt_dist(mpg_data)
Figures
Function ID
1-4
See Also
Other Plotting:
gt_plt_bar_pct()
,
gt_plt_bar_stack()
,
gt_plt_bar()
,
gt_plt_percentile()
,
gt_plt_point()
,
gt_plt_sparkline()
,
gt_plt_winloss()