ReporteRs (version 0.5.1)

addTable: Add a table into a document object

Description

Add a table into a document object

Usage

addTable(doc, data, layout.properties, header.labels,
    groupedheader.row, span.columns, col.types,
    columns.bg.colors, columns.font.colors, row.names, ...)

Arguments

doc

document object

data

(a data.frame or matrix object) to add

layout.properties

a tableProperties object to specify styles to use to format the table. optional

header.labels

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.

groupedheader.row

a named list whose elements define the upper header row (grouped header). Optional. Elements of that list are values and 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.

span.columns

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] )

col.types

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.

columns.bg.colors

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).

row.names

logical value - should the row.names be included in the table.

columns.font.colors

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).

...

further arguments passed to or from other methods..

Value

a document object

Details

The table below shows the display model used to format tables:

+--------------+---------------+

GROUPEDHEADER_1|GROUPEDHEADER_2|

+------+-------+-------+-------+

HEADER1|HEADER2|HEADER3|HEADER4|

+------+-------+-------+-------+

 x[1,1]| x[1,2]| x[1,3]|| x[1,4]|

+------+-------+-------+-------+

 x[2,1]| x[2,2]| x[2,3]|| x[2,4]|

+------+-------+-------+-------+

 x[3,1]| x[3,2]| x[3,3]|| x[3,4]|

+------+-------+-------+-------+

See Also

docx, addTable.docx , pptx, addTable.pptx , html, addTable.html

Examples

Run this code
# NOT RUN {
# add the first 5 lines of iris
doc <- addTable( doc, head( iris, n = 5 ) )

# demo span.columns
doc <- addTable( doc, iris[ 46:55,], span.columns = "Species" )

data( data_ReporteRs )
# add iris 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")
			)
	)
# }

Run the code above in your browser using DataCamp Workspace