
Last chance! 50% off unlimited learning
Sale ends in
Insert a table into the reveal
object.
# S3 method for reveal
addTable (doc, data, layout.properties,
header.labels, groupedheader.row = list(),
span.columns = character(0), col.types,
columns.bg.colors = list(),
columns.font.colors = list(), row.names = FALSE, ...)
the reveal
to use
data.frame
to add
a tableProperties
object
to specify styles to use to format the table. optional
a character whose elements define
labels to display in table headers instead of colnames.
Optional, if missing, headers will be filled with
data
column names.
a named list whose elements
define the upper header row (grouped header). Optional.
Elements of that list are \codevalues and
\codecolspan (list(values, colspan)
). Element
values
is a character vector containing labels to
display in the grouped header row. Element colspan
is an integer vector containing number of columns to span
for each values
.
a character vector specifying columns names where row merging should be done (if successive values in a column are the same ; if data[p,j]==data[p-1,j] )
a character whose elements define the formating style of columns via their data roles. Optional Possible values are : "character", "integer", "logical" , "double", "percent", "date", "datetime". If missing, factor and character will be formated as character , integer as integer and numeric as double.
A named list of character
vector. Define the background color of cells for a given
column. optional. Names are data
column names and
values are character vectors specifying cells background
colors. Each element of the list is a vector of length
nrow(data)
.
A named list of character
vector. Define the font color of cells per column.
optional. A name list, names are data
column
names and values are character vectors specifying cells
font colors. Each element of the list is a vector of
length nrow(data)
.
logical value - should the row.names be included in the table.
addTable arguments - see
addTable
.
an object of class "reveal"
.
# NOT RUN {
# Create a new document
doc = reveal( title = "title" )
# add a page where to add R outputs with title 'page example'
doc = addSlide( doc )
doc = addTitle( doc, "Iris dataset", level = 1 )
# add the first 5 lines of iris
doc <- addTable( doc, head( iris, n = 5 ) )
doc = addSlide( doc )
doc = addTitle( doc, "Iris sample dataset with span cells", level = 2 )
# demo span.columns
doc <- addTable( doc, iris[ 46:55,], span.columns = "Species" )
doc = addSlide( doc )
doc = addTitle( doc, "Dummy data and options demo", level = 1 )
data( data_ReporteRs )
# add dummy data 'data_ReporteRs' and customise some options
doc <- addTable( doc
, data = data_ReporteRs
, header.labels = c( "Header 1", "Header 2", "Header 3", "Header 4", "Header 5", "Header 6" )
, groupedheader.row = list( values = c("Grouped column 1", "Grouped column 2"), colspan = c(3, 3) )
, col.types = c( "character", "integer", "double", "date", "percent", "character" )
, columns.font.colors = list(
"col1" = c("#527578", "#84978F", "#ADA692", "#47423F")
, "col3" = c("#74A6BD", "#7195A3", "#D4E7ED", "#EB8540")
)
, columns.bg.colors = list(
"col2" = c("#527578", "#84978F", "#ADA692", "#47423F")
, "col4" = c("#74A6BD", "#7195A3", "#D4E7ED", "#EB8540")
)
)
# write the reveal object in a directory
reveal.directory <- "reveal_doc"
reveal.files = writeDoc( doc, directory = reveal.directory )
# }
Run the code above in your browser using DataLab