ReporteRs (version 0.5.9)

addTable.pptx: Insert a table into an pptx object

Description

Insert a table into the pptx object.

Usage

# S3 method for pptx
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, ...)

Arguments

doc

the pptx to use

data

data.frame 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 formatting 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).

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

row.names

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

...

addTable arguments - see addTable.

Value

an object of class "pptx".

Details

Width of the table is the width of the shape where table is added.

See Also

pptx, addTable , tableProperties, addFlexTable.pptx , FlexTable

Examples

Run this code
# NOT RUN {
#START_TAG_TEST
doc.filename = "addTable_example.pptx"

# set default font size to 24
options( "ReporteRs-fontsize" = 24 )

doc = pptx( title = "title" )

# add a slide with layout "Title and Content"
doc = addSlide( doc, slide.layout = "Title and Content" )

doc = addTitle( doc, "Title example 1" )
#
# simpliest usage
doc = addTable( doc, iris[ 1:10,] )

# add a slide with layout "Title and Content"
doc = addSlide( doc, slide.layout = "Title and Content" )


doc = addTitle( doc, "Title example 2" )
# demo span.columns
# Iris sample dataset with span cells on column Species
doc = addTable( doc, iris[ 46:55,], span.columns = "Species" )

# add a slide with layout "Title and Content"
doc = addSlide( doc, slide.layout = "Title and Content" )


doc = addTitle( doc, "Title example 3" )
#
# demo many options
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 object
writeDoc( doc, file = doc.filename )
#STOP_TAG_TEST
# }

Run the code above in your browser using DataLab