pptx: Create Microsoft PowerPoint document object representation

Description Usage Arguments Details Value Note References See Also Examples

View source: R/pptx.R

Description

Create a pptx object

Usage

1
2
3
4
5
6
7
8
pptx(title, template,
  list.definition = getOption("ReporteRs-list-definition"))

## S3 method for class 'pptx'
dim(x)

## S3 method for class 'pptx'
print(x, ...)

Arguments

title

"character" value: title of the document (in the doc properties).

template

"character" value, it represents the filename of the pptx file used as a template.

list.definition

a list definition to specify how ordered and unordered lists have to be formated. See list.settings. Default to getOption("ReporteRs-list-definition").

x

Object of class pptx

...

further arguments, not used.

Details

To send R output in a pptx document, a slide (see addSlide.pptx have to be added to the object first (because output is beeing written in slides).

Several methods can used to send R output into an object of class pptx.

Once object has content, user can write the pptx into a ".pptx" file, see writeDoc.

dim returns slide width and height, position and dimension of the next available shape in the current slide.

print print informations about an object of class pptx.

Value

an object of class pptx.

Note

Power Point 2007-2013 (*.pptx) file formats are the only supported files.

Document are manipulated in-memory ; a pptx's document is not written to the disk unless the writeDoc method has been called on the object.

References

Wikipedia: Office Open XML
http://en.wikipedia.org/wiki/Office_Open_XML

See Also

docx

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# set default font size to 10
options( "ReporteRs-fontsize" = 11 )

# Word document to write
pptx.file = "presentation_example.pptx"

# Create a new document
doc = pptx( title = "title" )

# display layouts names
slide.layouts( doc )

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

#set the main title
doc = addTitle( doc, "Presentation title" )
#set the sub-title
doc = addSubtitle( doc , "This document is generated with ReporteRs.")


################ TEXT DEMO ################

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

# add a title
doc = addTitle( doc, "Text demo" )
sometext = c( "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
	, "In sit amet ipsum tellus. Vivamus dignissim sit amet auctor."
	, "Quisque dictum tristique ligula."
)

# add simple text
doc = addParagraph( doc, value = sometext )

# Add "My tailor is rich" and "Cats and Dogs"
# format some of the pieces of text
pot1 = pot("My tailor"
	, textProperties(color="red" ) ) + " is " + pot("rich"
	, textProperties(font.weight="bold") )
pot2 = pot("Cats"
	, textProperties(color="red" )
	) + " and " + pot("Dogs"
	, textProperties(color="blue" ) )
doc = addParagraph(doc, set_of_paragraphs( pot1, pot2 ) )

################ PLOT DEMO ################
if( requireNamespace("ggplot2", quietly = TRUE) ){
  doc = addSlide( doc, slide.layout = "Title and Content" )
  doc = addTitle( doc, "Plot examples" )

  myplot = ggplot2::qplot(Sepal.Length, Petal.Length
    , data = iris, color = Species
    , size = Petal.Width, alpha = I(0.7)
)
  # Add titles and then 'myplot'
  doc = addPlot( doc, function( ) print( myplot ) )
}

################ FLEXTABLE DEMO ################
doc = addSlide( doc, slide.layout = "Title and Content" )
doc = addTitle( doc, "FlexTable example" )

# Create a FlexTable with data.frame mtcars, display rownames
# use different formatting properties for header and body
MyFTable = FlexTable( data = mtcars, add.rownames = TRUE,
	header.cell.props = cellProperties( background.color = "#00557F" ),
	header.text.props = textProperties( color = "white",
		font.size = 11, font.weight = "bold" ),
	body.text.props = textProperties( font.size = 10 )
)
# zebra stripes - alternate colored backgrounds on table rows
MyFTable = setZebraStyle( MyFTable, odd = "#E1EEf4", even = "white" )

# applies a border grid on table
MyFTable = setFlexTableBorders(MyFTable,
	inner.vertical = borderProperties( color="#0070A8", style="solid" ),
	inner.horizontal = borderNone(),
	outer.vertical = borderProperties( color = "#006699",
	  style = "solid", width = 2 ),
	outer.horizontal = borderProperties( color = "#006699",
	  style = "solid", width = 2 )
)

# add MyFTable into document
doc = addFlexTable( doc, MyFTable )

# write the doc
writeDoc( doc, file = pptx.file )


# get pptx page dimensions ------
doc = pptx( title = "title" )
doc = addSlide( doc, "Title and Content" )
dim(doc)

ReporteRs documentation built on April 1, 2018, 12:06 p.m.