addChartRightTextLeftPptx: Add a PPTX slide with chart on the right and text on the left

Description Usage Arguments See Also Examples

View source: R/reportPatentData.R

Description

Generate a commonly-used PPTX slide format where the patent chart is on the right and some text is on the left.

This function automates a number of steps used in formatting a pptx slide. It returns the ppt object with the new slide included.

Usage

1
2
3
4
addChartRightTextLeftPptx(ppt, plot, text, title,
  slide_layout = "Title and Content", Poffx = 5.3, Poffy = 0,
  Pwidth = 8, Pheight = 7.5, Toffx = 1, Toffy = 2, Twidth = 5,
  Theight = 5.5)

Arguments

ppt

A ppt object.

plot

A plot object from ggplot2.

text

A character vector of text, typically less than one paragraph in size.

title

A character title for a page. Default is NULL

slide_layout

The name of a slide layout, the same name as the names in a .potx powerpoint template file. Default is a Title and Content blank layout.

Poffx

Plot image x position from left top, inches. See addPlot. Default is 5.3.

Poffy

Plot image y position from left top, inches. See addPlot. Default is 0.

Pwidth

Plot image width, inches. See addPlot. Default is 8.

Pheight

Plot image height, inches. See addPlot. Default is 7.5

Toffx

Text image x position from left top, inches. See addPlot. Default is 1.

Toffy

Text image y position from left top, inches. See addPlot. Default is 2.

Twidth

Text image width, inches. See addPlot. Default is 5.

Theight

Text image height, inches. See addPlot. Default is 5.5.

See Also

pptx, addFullImagePptx

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
sumo <- cleanPatentData(patentData = patentr::acars, columnsExpected = sumobrainColumns,
                        cleanNames = sumobrainNames,
                        dateFields = sumobrainDateFields,
                        dateOrders = sumobrainDateOrder,
                        deduplicate = TRUE,
                        cakcDict = patentr::cakcDict,
                        docLengthTypesDict = patentr::docLengthTypesDict,
                        keepType = "grant",
                        firstAssigneeOnly = TRUE,
                        assigneeSep = ";",
                        stopWords = patentr::assigneeStopWords)

# note that in reality, you need a patent analyst to carefully score
# these patents, the score here is for demonstrational purposes
score <- round(rnorm(dim(sumo)[1],mean=1.4,sd=0.9))
score[score>3] <- 3
score[score<0] <- 0
sumo$score <- score
sumo$assigneeSmall <- strtrim(sumo$assigneeClean,12)
category <- c("system","control algorithm","product","control system", "communication")
c <- round(rnorm(dim(sumo)[1],mean=2.5,sd=1.5))
c[c>5] <- 5; c[c<1] <- 1
sumo$category <- category[c]
feature1 <- c("adaptive", "park", "lane", NA,NA,NA,NA,NA, 
"brake", "steer","accelerate","deactivate")
f <- round(rnorm(dim(sumo)[1],mean=5,sd=1))
l <- length(feature1)
f[f>l] <- l; f[f<1] <- 1
sumo$feature1 <- c(feature1,feature1[f])[1:dim(sumo)[1]]

flippedHistogram(sumo, "assigneeSmall","score",colors=scoreColors)
flippedHistogram(subset(sumo, score > 0), "assigneeSmall","score",colors=scoreColors)

flippedHistogram(subset(sumo, score > 2) ,"assigneeSmall","docType",colors=scoreColors,
                 recolor = TRUE)




# create a ppt
ppt <- ReporteRs::pptx(title="IP Update")
# view the types of layouts available by default
# slide.layouts(ppt)
layoutTitleContent = "Title and Content"

# first plot of top score (3) 
asdt <- summarizeColumns(subset(sumo,score > 2),'docType')
ppt <- 
  addChartRightTextLeftPptx(ppt = ppt,
                            plot = flippedHistogram(subset(sumo, score > 2) ,
                                                    "assigneeSmall","docType",
                                                    colors=scoreColors, 
                                                    recolor = TRUE), 
                            text = summaryText(asdt, "doc type", "doc types", 
                                               subset(sumo,score>2)$docType), 
                            title = "Doc Types for Top Score Docs", 
                            slide_layout = layoutTitleContent)

# top scores by assignee
ascore <- summarizeColumns(subset(sumo,score > 2),'assigneeSmall')
ppt <- 
  addChartRightTextLeftPptx(ppt = ppt,
                            plot = flippedHistogram(subset(sumo, score > 2) ,
                                                    "assigneeSmall","score",
                                                    colors=scoreColors, 
                                                    recolor = FALSE), 
                            text = summaryText(ascore, "assignee", "assignees", 
                                               subset(sumo,score>2)$assigneeSmall), 
                            title = "Assignees with Top Scores", 
                            slide_layout = layoutTitleContent)


# last plot is category
sc <- summarizeColumns(sumo,'category')
ppt <- 
  addChartRightTextLeftPptx(ppt = ppt,
                            plot = flippedHistogram(sumo ,"category",
                                                    "score", colors = scoreColors,
                                                    recolor = TRUE),
                            text = summaryText(sc, "category", "categories", sumo$category),
                            title = "Categories and Scores",
                            slide_layout = layoutTitleContent)

# find a data folder and write it out to your folder
# out <- paste("data/",Sys.Date(),"_exampleChartRightTextLeft.pptx",sep='')
# ReporteRs::writeDoc(ppt, out)

kamilien1/patentr documentation built on May 20, 2019, 7:19 a.m.