ReporteRs has functions to manage objects representing:

  • text formatting properties
  • paragraph formatting properties
  • border formatting properties
  • cell formatting properties.

With ReporteRs, some options can be used to reduce usage of some parameters. These are then used as default values for textProperties objects:

getOption('ReporteRs-fontsize')
## [1] 11
getOption('ReporteRs-default-font')
## [1] "Times New Roman"

Available formatting properties

Text formatting properties

Create a textProperties object that describes text formatting properties. It let you specify font name color, size, weight, etc.

textProperties objects can be used with function pot and when manipulating FlexTable objects.

Usage example

my_text = pot('My tailor', textProperties(color='#1163A5', font.size = 10) ) +
pot(' is ', textProperties(font.style = 'italic', color='gray', font.size = 12) ) +
pot('rich', textProperties(font.weight='bold', color='#D63C3A', font.size = 10) )
my_text

My tailor is rich

MyFTable = vanilla.table( data = mtcars[1:5, ], add.rownames = TRUE )
MyFTable[ 1, 1, to = "header"] = my_text
MyFTable

My tailor is rich

mpg

cyl

disp

hp

drat

wt

qsec

vs

am

gear

carb

Mazda RX4

21.0

6

160

110

3.90

2.620

16.46

0

1

4

4

Mazda RX4 Wag

21.0

6

160

110

3.90

2.875

17.02

0

1

4

4

Datsun 710

22.8

4

108

93

3.85

2.320

18.61

1

1

4

1

Hornet 4 Drive

21.4

6

258

110

3.08

3.215

19.44

1

0

3

1

Hornet Sportabout

18.7

8

360

175

3.15

3.440

17.02

0

0

3

2

Paragraph formatting properties

Create a parProperties object that describes paragraph formatting properties. It let you specify text alignment, paddings, the kind of numbering if paragraphs are a list, etc.

A parProperties object is used by several functions, ie. addPlot, addFlexTable, addParagraph.

Usage

MyFTable = FlexTable( data = iris[1:5, ] )
MyFTable[ 1:2, 4:5] = parProperties( text.align = 'right', padding = 3 )
MyFTable

Sepal.Length

Sepal.Width

Petal.Length

Petal.Width

Species

5.1

3.5

1.4

0.2

setosa

4.9

3.0

1.4

0.2

setosa

4.7

3.2

1.3

0.2

setosa

4.6

3.1

1.5

0.2

setosa

5.0

3.6

1.4

0.2

setosa

Cell formatting properties

Create a cellProperties object that describes cell formatting properties. It let you specify cell borders, background color, etc.

A cellProperties object is used with FlexTable objects.

Usage

MyFTable = FlexTable( data = iris[1:5, ] )
MyFTable[ 1:2, 4:5] = cellProperties( background.color = 'wheat' )
MyFTable

Sepal.Length

Sepal.Width

Petal.Length

Petal.Width

Species

5.1

3.5

1.4

0.2

setosa

4.9

3.0

1.4

0.2

setosa

4.7

3.2

1.3

0.2

setosa

4.6

3.1

1.5

0.2

setosa

5.0

3.6

1.4

0.2

setosa

Border formatting properties

Create a borderProperties object that describes border formatting properties.

A borderProperties object is used with FlexTable objects and with parProperties objects.

Usage

MyFTable = FlexTable( data = iris[1:5, ] )
MyFTable[ 1, to = "header", side = "bottom"] = borderProperties(color="orange", style="solid", width=4)
MyFTable

Sepal.Length

Sepal.Width

Petal.Length

Petal.Width

Species

5.1

3.5

1.4

0.2

setosa

4.9

3.0

1.4

0.2

setosa

4.7

3.2

1.3

0.2

setosa

4.6

3.1

1.5

0.2

setosa

5.0

3.6

1.4

0.2

setosa

Change properties

To get modified copies of textProperties, parProperties, and cellProperties objects, use the function chprop.

It makes the code less verbose and makes easier to specify formatting properties on FlexTable.

base_text_prop = textProperties( font.size = 10, color = "#3D3234" )
base_par_prop = parProperties( text.align = "right" )
base_cell_prop = cellProperties( padding = 0 )
MyFTable <- vanilla.table( data = iris[1:5, ])
MyFTable[] <- base_par_prop
MyFTable[ , 5 ] <- chprop( base_par_prop, text.align = "center")
MyFTable[] <- base_cell_prop
MyFTable[ 3, ] <- chprop( base_cell_prop, background.color = "orange" )
MyFTable[] <- base_text_prop
MyFTable[ , 1] <- chprop( base_text_prop, font.weight = "bold" )
MyFTable

Sepal.Length

Sepal.Width

Petal.Length

Petal.Width

Species

5.1

3.5

1.4

0.2

setosa

4.9

3.0

1.4

0.2

setosa

4.7

3.2

1.3

0.2

setosa

4.6

3.1

1.5

0.2

setosa

5.0

3.6

1.4

0.2

setosa

Shorcut functions

The following functions are shortcuts for textProperties function calls:

  • textNormal: return default textProperties object.
  • textBold: return a textProperties object with bold font.
  • textBoldItalic: return a textProperties object with bold italic font.
  • textItalic: return a textProperties object with italic font.

The following functions are shortcuts for parProperties function calls:

  • parRight: return a parProperties object with right text alignment.
  • parLeft: return a parProperties object with left text alignment.
  • parJustify: return a parProperties object with justified text alignment.
  • parCenter: return a parProperties object with center text alignment.
MyFTable = vanilla.table( data = iris[1:5, ] )
MyFTable[ to = "header" ] = textBold()
MyFTable[ , 5 ] = textItalic()
MyFTable[ , 1:4] = parRight()
MyFTable

Sepal.Length

Sepal.Width

Petal.Length

Petal.Width

Species

5.1

3.5

1.4

0.2

setosa

4.9

3.0

1.4

0.2

setosa

4.7

3.2

1.3

0.2

setosa

4.6

3.1

1.5

0.2

setosa

5.0

3.6

1.4

0.2

setosa

The following functions are shortcuts for borderProperties function calls: borderDashed, borderDotted, borderSolid and borderNone.

The following functions are shortcuts for cellProperties function calls: cellBorderNone, cellBorderBottom, cellBorderTop and cellBorderTB.