nice_table.default.Rd
This function takes a data frame and formats it into a nicely formatted HTML
table using the gt
packages.
# Default S3 method
nice_table(
x,
title = NULL,
footnote = NULL,
spanner = NULL,
row_group = NULL,
row_group_order = NULL,
rownames = NULL,
file = NULL,
cols_label = NULL,
decimals = NULL,
round = NULL,
label_na = NULL,
markdown = FALSE,
gt = NULL,
sort = NULL,
sort_decreasing = FALSE,
...
)
The data frame to be formatted into a table
Title string.
Add footnote
List with information on grouping columns. E.g. spanner = list("M" = 2:3, "SD" = 4:6)
.
List with information on grouping rows row_group = list("Start" = 1:2, "That is the second" = 3:5)
List with information on grouping order.
Logical or NULL
. If TRUE, rownames are shown. If NULL
,
rownames are shown when they are not identical to
as.character(1:nrow(x))
.
Character string with filename. If set, an additional file is
exported (html or docx format is possible). If set TRUE
, a filename is
automatically created based on the title.
List with renaming information for columns (old_name = new_name).
Number of decimals that will be printed.
Number of digits to which numbers should be rounded.
= Label for replacing missing values.
If TRUE, interprets cell content as markdown.
Additional arguments passed to gt::gt()
Various arguments for backward compatibility.
A gt table object.
df <- data.frame(
x = 1:5, y = rnorm(5, mean = 10, sd = 12),
c = letters[5:1], d = sample(letters, 5)
)
nice_table(
df,
title = "A nice title",
footnote = c("Footnote 1", "Footnote 2"),
spanner = list("One" = 1:2, "Two" = 3:4),
row_group = list("Start" = 1:2, "That is the second" = 3:5),
cols_label = list(x = "First", y = "Second", c = "Third", d = "Fourth"),
decimals = 1
)
Table
A nice title
First
Second
Third
Fourth
Start
That is the second
Note. Footnote 1. Footnote 2.