View source: R/create_table_graphic.R
create_table_graphic | R Documentation |
Function creates a ggplot2 graphic table from a data frame.
Function creates a simple, non-scrollable static table to be laid out with other ggplot2 graphics. The
function is based on grid
along with the gtable
package.
For estimating the overall height of the table consider that each row of the table is 0.2 inches high, .54 inches for heading and if a title is defined then add an additional 0.5 inches.
create_table_graphic(
df = NULL,
table_width = 8,
head_color = "black",
head_fill = "white",
head_font_sz = 14,
cell_color = "black",
cell_fill = "white",
cell_font_sz = 11,
cell_just = "center",
cell_hor_pos = 0.5,
title = NULL,
title_font_sz = 16,
show_row_names = TRUE,
row_names_width = 0.5,
return_gtable = FALSE
)
df |
The target data frame from which to graph. |
table_width |
The overall table width in inches. |
head_color |
Color of the headings foreground. |
head_fill |
Color of the headings background. |
head_font_sz |
Font size of the headings. |
cell_color |
Color of the cells foreground. |
cell_fill |
Color of the cells background. |
cell_font_sz |
Font size of the cells. |
cell_just |
An string that sets justification of the cell content. Acceptable values are "left" and "right" and "center". |
cell_hor_pos |
A numeric that sets the starting horizontal location of text in a cell. Acceptable range from 0.0 to 1.0. |
title |
A string that sets the table title. |
title_font_sz |
Font size of the title. |
show_row_names |
A logical that controls the appearance of row names in the data frame. |
row_names_width |
The width of the column for row names in inches. |
return_gtable |
A logical which if |
A gtable or ggplot class object.
library(grid)
library(gtable)
library(ggplotify)
library(RplotterPkg)
RplotterPkg::create_table_graphic(
df = RplotterPkg::car_stats,
table_width = 7,
show_row_names = TRUE,
cell_just = "right",
cell_hor_pos = 0.95,
title = "Average Measures by Cylinders"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.