rmdTable | R Documentation |
Construct a table in html, pdf, or word document, format the numeric columns, and automatically setting column widths.
rmdTable(dataDf, header = list(colnames(dataDf)), footer = NULL,
colWidths = NULL, fontSize = 11, caption = NULL,
rowHeaderInd = NULL, isDocx = TRUE, nRowScroll = 20,
nRowDisplay = 200, maxTableWidth = 7,
theme = c("zebra","box","booktabs","vanilla","tron","vader"),
char2space=NULL, splitCamelCase=FALSE,
footerFontSize=9, minFontSize=9,...)
myFlexTable(dataDf,header=list(colnames(dataDf)), footer = NULL,
colWidths = NULL, fontSize = 11, caption = NULL,
rowHeaderInd = NULL, mergeBodyColumn = TRUE, maxTableWidth = 7,
theme = c("zebra","box","booktabs","vanilla","tron","vader"),
char2space=NULL, splitCamelCase=FALSE,
footerFontSize=9, minFontSize=9,...)
myKable(dataDf,header = list(colnames(dataDf)), footer = NULL,
caption = NULL, rowHeaderInd = NULL, nRowScroll = 20,
theme = c("zebra","box","vanilla"),...)
setFlexTableFontSize(ft,fontSize,footerFontSize=9)
dataDf |
(data.frame or matrix) the content of the table to be displayed |
header |
(character or list of character vectors, list(colnames(dataDf)))
|
footer |
(character or list of character vectors, NULL)
|
colWidths |
(character or numeric vector, NULL). For |
fontSize |
(integer, 10) For |
caption |
(character, NULL) the caption of the table. |
rowHeaderInd |
(integer, NULL). Row headers are the columns in the left of table body serving as headers for rows in the table body. |
mergeBodyColumn |
(boolean, TRUE) |
isDocx |
(boolean, TRUE) if |
nRowScroll |
(integer, 20) For |
nRowDisplay |
(integer, 200) For |
theme |
(character) The theme of the table. |
maxTableWidth,minFontSize |
see those parameters in |
char2space |
(character string, NULL) A regular expression. Should the characters represented by this regular expression in the bottom row of column header be changed to space? If so, when the column header is wrapped, the wrapping happens at a space in stead of the middle of a word. For example, setting |
splitCamelCase |
(boolean, FALSE) Should the camel cases in the 1st row of column header be split into separated words? for example, change "youMadeItLOL" into "you Made It LOL". If so, when a column header in camel case is wrapped, the wrapping happens at a space in stead of the middle of a word. |
footerFontSize |
(integer,9) For |
ft |
a flextable object |
intTypeCutoff |
(integer, 10) if a number is an integer and its absolute value is less than intTypeCutoff, don't format. Set NULL to disable. |
... |
if |
myFlexTable
and myKable
are wrapper functions of flextable
and kable
, and rmdTable
is a wrapper of the two wrappers with isDocx TRUE
referring to myFlexTable
and FALSE
to myKable
(flextable or kable object)
Numeric columns are formatted using num2formattedStr
. If a numeric column is not formatted in the displayed table, probably it is because its data type in dataDf
is not numeric
or integer
.
num2formattedStr
, flextable
, kable
library(wfr)
df1=data.frame(A=c("a","a","b3"),
B=c("b1","b2","b3"),
C1=c(1001.123,58.04,32.01),
C2=c(-0.00321, 0.0121, 0.325))
header=list(c('A','A','C','C'),
c('A','A','C1','C2'))
footer=list(c("A","Arkansas$~ref$",'1','header'),
c("C1","Kansas$^ref$",'x','header'),
c('a',"Arizona",'2','body'))
rmdTable(df1,header = header,
rowHeaderInd = 2,
footer = footer,
caption = "my first table",
colWidths = c(2,1,1,1),
fontSize = 12, isDocx = TRUE)
colWidths = "2,1,1,1"
header = "A | A | C | C || A | A | C1 | C2"
footer = "A|Arkansas$~ref$|1|header
|| C1|Kansas$^ref$|x|header
|| a|Arizona|2|body"
rmdTable(df1,header = header,
rowHeaderInd = 2,
footer = footer,
caption = "my second table",
colWidths = colWidths,
fontSize = 12, isDocx = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.