| gentlg | R Documentation |
tidytlg tableGenerate and output a huxtable with desired properties
During this function call, the huxtable can be written to an RTF or
displayed in HTML. gentlg is vectorized, see parameter descriptions
to learn for which arguments.
gentlg(
huxme = NULL,
tlf = "Table",
format = "rtf",
colspan = NULL,
idvars = NULL,
plotnames = NULL,
plotwidth = NULL,
plotheight = NULL,
wcol = 0.45,
orientation = "portrait",
opath = ".",
title_file = NULL,
file = NULL,
title = NULL,
footers = NULL,
print.hux = TRUE,
watermark = NULL,
colheader = NULL,
pagenum = FALSE,
bottom_borders = "old_format",
border_fns = list(),
alignments = list()
)
huxme |
(optional) For tables and listings, A list of input dataframes
containing all columns of interest. For graphs, either |
tlf |
(optional) String, representing the output choice. Choices are
|
format |
(optional) String, representing the output format. Choices are
|
colspan |
(optional) A list of character vectors representing the spanning headers to be used for the table or listing. The first vector represents the top spanning header, etc. Each vector should have a length equal to the number of columns in the output data frame. A spanning header is identified through the use of the same column name in adjacent elements. Vectorized. |
idvars |
(optional) Character vector defining the columns of a listing
where repeated values should be removed recursively. If |
plotnames |
(optional) Character vector containing the names of the PNG
files, with their extension to be incorporated for figure outputs.
The PNG files need to be located in the path defined by the
parameter |
plotwidth |
(optional) Numerical value that indicates the plot width in cm for figure outputs. (Default = 6) |
plotheight |
(optional) Numerical value that indicates the plot height in cm for figure outputs. (Default = 5) |
wcol |
(optional) Can be a single numerical value that represents the
width of the first column or a vector, specifying the lengths of all columns
in the final table or listing. |
orientation |
(optional) String: "portrait" or "landscape". (Default = "portrait") |
opath |
(optional) File path pointing to the output files (including PNG files for graphs). (Default = "."). |
title_file |
An Excel file that will be read in
with |
file |
(required) String. Output identifier.
File name will be adjusted to be lowercase and have |
title |
(required) String. Title of the output. Vectorized. |
footers |
(optional) Character vector, containing strings of footnotes to be included. Vectorized. |
print.hux |
(optional) Logical, indicating whether the output should be
printed to RTF |
watermark |
(optional) String containing the desired watermark for RTF outputs. Vectorized. |
colheader |
(optional) Character vector that contains the column labels
for a table or listing. Default uses the column labels of |
pagenum |
(optional) Logical. When true page numbers are added on the
right side of the footer section in the format page |
bottom_borders |
(optional) Matrix or |
border_fns |
(optional) List. A list of functions that transform
the matrix passed to |
alignments |
(optional) List of named lists. Vectorized.
(Default = |
A list of formatted huxtables with desired
properties for output to an RTF or HTML.
Huxme DetailsFor tables and listings, formatting of the output can be dictated through the
formatting columns
(newrows, indentme, boldme, newpage), present in the input dataframe.
The final huxtable will display all columns of the input dataframe, except
any recognized formatting or sorting columns.
For tables, the algorithm uses the column label as first column.
The remaining columns are treated as summary columns.
For graphs, you can pass a ggplot object directly
into huxme and gentlg will save a PNG with with ggplot2::ggsave()
and output an RTF.
Steven Haesendonckx shaesen2@its.jnj.com
Pelagia Alexandra Papadopoulou ppapadop@its.jnj.com
https://github.com/hughjonesd/huxtable
final <- data.frame(
label = c(
"Overall", "Safety Analysis Set",
"Any Adverse event{\\super a}", "- Serious Adverse Event"
),
Drug_A = c("", "40", "10 (25%)", "0"),
Drug_B = c("", "40", "10 (25%)", "0"),
anbr = c(1, 2, 3, 4),
roworder = c(1, 1, 1, 1),
boldme = c(1, 0, 0, 0),
newrows = c(0, 0, 1, 0),
indentme = c(0, 0, 0, 1),
newpage = c(0, 0, 0, 0)
)
# Produce output in rtf format
gentlg(
huxme = final,
wcol = c(0.70, 0.15, 0.15),
file = "TSFAEX",
title = "This is Amazing Demonstration 1",
footers = c(
"Note: For demonstrative purposes only",
"{\\super a} Subjects are counted once for any given event."
)
)
# Pass in column headers instead of using variable name
gentlg(
huxme = final,
wcol = c(0.70, 0.15, 0.15),
file = "TSFAEX",
colheader = c("", "Drug A", "Drug B"),
title = "This is Amazing Demonstration 1",
footers = c(
"Note: For demonstrative purposes only",
"{\\super a} Subjects are counted once for any given event."
)
)
# Add spanning bottom borders under the cells in the second row
gentlg(
huxme = final,
wcol = c(0.70, 0.15, 0.15),
file = "TSFAEX",
colheader = c("", "Drug A", "Drug B"),
title = "This is Amazing Demonstration 1",
footers = c(
"Note: For demonstrative purposes only",
"{\\super a} Subjects are counted once for any given event."
),
border_fns = list(spanning_borders(2))
)
# Use a watermark
gentlg(
huxme = final,
wcol = c(0.70, 0.15, 0.15),
file = "TSFAEX",
colheader = c("", "Drug A", "Drug B"),
title = "This is Amazing Demonstration 1",
footers = c(
"Note: For demonstrative purposes only",
"{\\super a} Subjects are counted once for any given event."
),
watermark = "Confidential"
)
# Set alignments
gentlg(
huxme = final,
file = "TSFAEX",
alignments = list(
# Align the second column to the left
list(row = 1:7, col = 2, value = "left"),
# Align cell "Drug: B" to the right
list(row = 2, col = 3, value = "right")
)
)
# Produce output in HTML format
hux <- gentlg(
huxme = final,
file = "TSFAEX",
colheader = c("", "Drug A", "Drug B"),
title = "This is Amazing Demonstration 1",
footers = c(
"Note: For demonstrative purposes only",
"{\\super a} Subjects are counted once for any given event."
),
watermark = "Confidential",
format = "HTML",
print.hux = FALSE
)
# Export to HTML page
huxtable::quick_html(hux, file = "TSFAEX.html", open = FALSE)
# clean up.
file.remove("TSFAEX.html", "tsfaex.rtf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.