Skip to content
This repository was archived by the owner on Mar 23, 2020. It is now read-only.

Commit 3abd6e7

Browse files
committed
roxygen update
1 parent f94ecf2 commit 3abd6e7

17 files changed

+610
-225
lines changed

man/FlexTable.Rd

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ Merging cells can be done with functions
8080
#START_TAG_TEST
8181
#####################################################################
8282

83+
# set default font size to 10
84+
options( "ReporteRs-fontsize" = 10 )
85+
8386
# Create a FlexTable with data.frame mtcars, display rownames
8487
# use different formatting properties for header and body cells
8588
MyFTable = FlexTable( data = mtcars, add.rownames = TRUE
@@ -96,6 +99,51 @@ MyFTable = setFlexTableBorders(MyFTable
9699
, outer.vertical = borderProperties( color = "#EDBD3E", style = "solid" )
97100
, outer.horizontal = borderProperties( color = "#EDBD3E", style = "solid" )
98101
)
102+
#####################################################################
103+
104+
# set default font size to 10
105+
options( "ReporteRs-fontsize" = 10 )
106+
107+
# a summary of mtcars
108+
dataset = aggregate( mtcars[, c("disp", "mpg", "wt")]
109+
, by = mtcars[, c("cyl", "gear", "carb")]
110+
, FUN = mean )
111+
dataset = dataset[ order(dataset$cyl, dataset$gear, dataset$carb), ]
112+
113+
114+
# set cell padding defaut to 2
115+
baseCellProp = cellProperties( padding = 2 )
116+
117+
# Create a FlexTable with data.frame dataset
118+
MyFTable = FlexTable( data = dataset
119+
, body.cell.props = baseCellProp
120+
, header.cell.props = baseCellProp
121+
, header.par.props = parProperties(text.align = "right" )
122+
)
123+
124+
# set columns widths (in inches)
125+
MyFTable = setFlexTableWidths( MyFTable, widths = c(0.5, 0.5, 0.5, 0.7, 0.7, 0.7) )
126+
127+
# span successive identical cells within column 1, 2 and 3
128+
MyFTable = spanFlexTableRows( MyFTable, j = 1, runs = as.character( dataset$cyl ) )
129+
MyFTable = spanFlexTableRows( MyFTable, j = 2, runs = as.character( dataset$gear ) )
130+
MyFTable = spanFlexTableRows( MyFTable, j = 3, runs = as.character( dataset$carb ) )
131+
132+
# overwrites some text formatting properties
133+
MyFTable[dataset$wt < 3, 6] = textProperties( color="#003366")
134+
MyFTable[dataset$mpg < 20, 5] = textProperties( color="#993300")
135+
136+
# overwrites some paragraph formatting properties
137+
MyFTable[, 1:3] = parProperties(text.align = "center")
138+
MyFTable[, 4:6] = parProperties(text.align = "right")
139+
140+
# applies a border grid on table
141+
MyFTable = setFlexTableBorders( MyFTable, footer=TRUE
142+
, inner.vertical = borderProperties( color = "#666666" )
143+
, inner.horizontal = borderProperties( color = "#666666" )
144+
, outer.vertical = borderProperties( width = 2, color = "#666666" )
145+
, outer.horizontal = borderProperties( width = 2, color = "#666666" )
146+
)
99147
#STOP_TAG_TEST
100148
}
101149
\seealso{

man/addFlexTable.docx.Rd

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,19 @@ Insert a FlexTable into a docx object
3030
}
3131
\examples{
3232
#START_TAG_TEST
33+
doc.filename = "addFlexTable_example.docx"
34+
35+
# set default font size to 10
36+
options( "ReporteRs-fontsize" = 10 )
37+
3338
doc = docx( )
3439

35-
doc = addTitle( doc, "Title example", level = 1 )
40+
doc = addTitle( doc, "Title example 1", level = 1 )
3641
#####################################################################
3742

43+
# set default font size to 10
44+
options( "ReporteRs-fontsize" = 10 )
45+
3846
# Create a FlexTable with data.frame mtcars, display rownames
3947
# use different formatting properties for header and body cells
4048
MyFTable = FlexTable( data = mtcars, add.rownames = TRUE
@@ -52,18 +60,21 @@ MyFTable = setFlexTableBorders(MyFTable
5260
, outer.horizontal = borderProperties( color = "#EDBD3E", style = "solid" )
5361
)
5462

63+
# add MyFTable into document
5564
doc = addFlexTable( doc, MyFTable )
5665

57-
doc = addTitle( doc, "Title example", level = 1 )
66+
doc = addTitle( doc, "Title example 2", level = 1 )
5867
#####################################################################
5968

69+
# set default font size to 10
70+
options( "ReporteRs-fontsize" = 10 )
71+
6072
# a summary of mtcars
6173
dataset = aggregate( mtcars[, c("disp", "mpg", "wt")]
6274
, by = mtcars[, c("cyl", "gear", "carb")]
6375
, FUN = mean )
6476
dataset = dataset[ order(dataset$cyl, dataset$gear, dataset$carb), ]
6577

66-
options( "ReporteRs-fontsize" = 9 )
6778

6879
# set cell padding defaut to 2
6980
baseCellProp = cellProperties( padding = 2 )
@@ -99,9 +110,11 @@ MyFTable = setFlexTableBorders( MyFTable, footer=TRUE
99110
, outer.horizontal = borderProperties( width = 2, color = "#666666" )
100111
)
101112

113+
# add MyFTable into document
102114
doc = addFlexTable( doc, MyFTable )
103115

104-
writeDoc( doc, file = "addFlexTable_example.docx" )
116+
# Write the object
117+
writeDoc( doc, file = doc.filename )
105118
#STOP_TAG_TEST
106119
}
107120
\seealso{

man/addFlexTable.html.Rd

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,22 @@ Insert a FlexTable into a docx object
1919
}
2020
\examples{
2121
#START_TAG_TEST
22+
doc.dirname = "addTable_example"
23+
24+
# set default font size to 10
25+
options( "ReporteRs-fontsize" = 10 )
26+
27+
doc = html()
28+
29+
# add a page with title "page example"
30+
doc = addPage( doc, title = "page example" )
31+
32+
doc = addTitle( doc, "Title example 1", level = 1 )
2233
#####################################################################
2334

35+
# set default font size to 10
36+
options( "ReporteRs-fontsize" = 10 )
37+
2438
# Create a FlexTable with data.frame mtcars, display rownames
2539
# use different formatting properties for header and body cells
2640
MyFTable = FlexTable( data = mtcars, add.rownames = TRUE
@@ -37,10 +51,62 @@ MyFTable = setFlexTableBorders(MyFTable
3751
, outer.vertical = borderProperties( color = "#EDBD3E", style = "solid" )
3852
, outer.horizontal = borderProperties( color = "#EDBD3E", style = "solid" )
3953
)
40-
doc = html( title = "title" )
41-
doc = addPage( doc, title = "Example" )
54+
55+
# add MyFTable into document
56+
doc = addFlexTable( doc, MyFTable )
57+
58+
doc = addTitle( doc, "Title example 2", level = 1 )
59+
#####################################################################
60+
61+
# set default font size to 10
62+
options( "ReporteRs-fontsize" = 10 )
63+
64+
# a summary of mtcars
65+
dataset = aggregate( mtcars[, c("disp", "mpg", "wt")]
66+
, by = mtcars[, c("cyl", "gear", "carb")]
67+
, FUN = mean )
68+
dataset = dataset[ order(dataset$cyl, dataset$gear, dataset$carb), ]
69+
70+
71+
# set cell padding defaut to 2
72+
baseCellProp = cellProperties( padding = 2 )
73+
74+
# Create a FlexTable with data.frame dataset
75+
MyFTable = FlexTable( data = dataset
76+
, body.cell.props = baseCellProp
77+
, header.cell.props = baseCellProp
78+
, header.par.props = parProperties(text.align = "right" )
79+
)
80+
81+
# set columns widths (in inches)
82+
MyFTable = setFlexTableWidths( MyFTable, widths = c(0.5, 0.5, 0.5, 0.7, 0.7, 0.7) )
83+
84+
# span successive identical cells within column 1, 2 and 3
85+
MyFTable = spanFlexTableRows( MyFTable, j = 1, runs = as.character( dataset$cyl ) )
86+
MyFTable = spanFlexTableRows( MyFTable, j = 2, runs = as.character( dataset$gear ) )
87+
MyFTable = spanFlexTableRows( MyFTable, j = 3, runs = as.character( dataset$carb ) )
88+
89+
# overwrites some text formatting properties
90+
MyFTable[dataset$wt < 3, 6] = textProperties( color="#003366")
91+
MyFTable[dataset$mpg < 20, 5] = textProperties( color="#993300")
92+
93+
# overwrites some paragraph formatting properties
94+
MyFTable[, 1:3] = parProperties(text.align = "center")
95+
MyFTable[, 4:6] = parProperties(text.align = "right")
96+
97+
# applies a border grid on table
98+
MyFTable = setFlexTableBorders( MyFTable, footer=TRUE
99+
, inner.vertical = borderProperties( color = "#666666" )
100+
, inner.horizontal = borderProperties( color = "#666666" )
101+
, outer.vertical = borderProperties( width = 2, color = "#666666" )
102+
, outer.horizontal = borderProperties( width = 2, color = "#666666" )
103+
)
104+
105+
# add MyFTable into document
42106
doc = addFlexTable( doc, MyFTable )
43-
writeDoc( doc, "addFlexTable_example")
107+
108+
# Write the object
109+
writeDoc( doc, directory = doc.dirname )
44110
#STOP_TAG_TEST
45111
}
46112
\seealso{

man/addFlexTable.pptx.Rd

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,22 @@ Insert a FlexTable into a pptx object
1919
}
2020
\examples{
2121
#START_TAG_TEST
22+
doc.filename = "addFlexTable_example.pptx"
23+
24+
# set default font size to 24
25+
options( "ReporteRs-fontsize" = 24 )
26+
27+
doc = pptx( title = "title" )
28+
29+
# add a slide with layout "Title and Content"
30+
doc = addSlide( doc, slide.layout = "Title and Content" )
31+
32+
doc = addTitle( doc, "Title example 1", level = 1 )
2233
#####################################################################
2334

35+
# set default font size to 10
36+
options( "ReporteRs-fontsize" = 10 )
37+
2438
# Create a FlexTable with data.frame mtcars, display rownames
2539
# use different formatting properties for header and body cells
2640
MyFTable = FlexTable( data = mtcars, add.rownames = TRUE
@@ -37,10 +51,65 @@ MyFTable = setFlexTableBorders(MyFTable
3751
, outer.vertical = borderProperties( color = "#EDBD3E", style = "solid" )
3852
, outer.horizontal = borderProperties( color = "#EDBD3E", style = "solid" )
3953
)
40-
doc = pptx( title = "title" )
54+
55+
# add MyFTable into document
56+
doc = addFlexTable( doc, MyFTable )
57+
58+
# add a slide with layout "Title and Content"
4159
doc = addSlide( doc, slide.layout = "Title and Content" )
60+
61+
doc = addTitle( doc, "Title example 2", level = 1 )
62+
#####################################################################
63+
64+
# set default font size to 10
65+
options( "ReporteRs-fontsize" = 10 )
66+
67+
# a summary of mtcars
68+
dataset = aggregate( mtcars[, c("disp", "mpg", "wt")]
69+
, by = mtcars[, c("cyl", "gear", "carb")]
70+
, FUN = mean )
71+
dataset = dataset[ order(dataset$cyl, dataset$gear, dataset$carb), ]
72+
73+
74+
# set cell padding defaut to 2
75+
baseCellProp = cellProperties( padding = 2 )
76+
77+
# Create a FlexTable with data.frame dataset
78+
MyFTable = FlexTable( data = dataset
79+
, body.cell.props = baseCellProp
80+
, header.cell.props = baseCellProp
81+
, header.par.props = parProperties(text.align = "right" )
82+
)
83+
84+
# set columns widths (in inches)
85+
MyFTable = setFlexTableWidths( MyFTable, widths = c(0.5, 0.5, 0.5, 0.7, 0.7, 0.7) )
86+
87+
# span successive identical cells within column 1, 2 and 3
88+
MyFTable = spanFlexTableRows( MyFTable, j = 1, runs = as.character( dataset$cyl ) )
89+
MyFTable = spanFlexTableRows( MyFTable, j = 2, runs = as.character( dataset$gear ) )
90+
MyFTable = spanFlexTableRows( MyFTable, j = 3, runs = as.character( dataset$carb ) )
91+
92+
# overwrites some text formatting properties
93+
MyFTable[dataset$wt < 3, 6] = textProperties( color="#003366")
94+
MyFTable[dataset$mpg < 20, 5] = textProperties( color="#993300")
95+
96+
# overwrites some paragraph formatting properties
97+
MyFTable[, 1:3] = parProperties(text.align = "center")
98+
MyFTable[, 4:6] = parProperties(text.align = "right")
99+
100+
# applies a border grid on table
101+
MyFTable = setFlexTableBorders( MyFTable, footer=TRUE
102+
, inner.vertical = borderProperties( color = "#666666" )
103+
, inner.horizontal = borderProperties( color = "#666666" )
104+
, outer.vertical = borderProperties( width = 2, color = "#666666" )
105+
, outer.horizontal = borderProperties( width = 2, color = "#666666" )
106+
)
107+
108+
# add MyFTable into document
42109
doc = addFlexTable( doc, MyFTable )
43-
writeDoc( doc, "addFlexTable_example.pptx")
110+
111+
# Write the object
112+
writeDoc( doc, file = doc.filename )
44113
#STOP_TAG_TEST
45114
}
46115
\seealso{

man/addParagraph.docx.Rd

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,48 @@ Insert paragraph(s) of text into a \code{docx} object
3030
}
3131
\examples{
3232
#START_TAG_TEST
33-
# Create a new document
34-
doc = docx( title = "title" )
35-
36-
# Add "Hello World" into the document doc with
37-
# stylename "Normal". Run the following code to
38-
# see available stylenames:
39-
# \\code{styles(doc)}
40-
doc = addParagraph(doc, "Hello Word!", "Normal");
41-
42-
# Add into the document : "My tailor is rich" and "Cats and Dogs"
43-
# format some of the pieces of text
44-
pot1 = pot("My tailor", textProperties(color="red") ) + " is " + pot("rich"
45-
, textProperties(font.weight="bold") )
46-
pot2 = pot("Cats", textProperties(color="red") ) + " and " + pot("Dogs"
47-
, textProperties(color="blue") )
33+
doc.filename = "addParagraph_example.docx"
34+
35+
# set default font size to 10
36+
options( "ReporteRs-fontsize" = 10 )
37+
38+
doc = docx( )
39+
40+
# returns available stylenames
41+
styles( doc )
42+
43+
doc = addTitle( doc, "Title example 1", level = 1 )
44+
45+
# Add "Hello World" into the document doc
46+
doc = addParagraph(doc, "Hello Word", stylename = "Normal" )
47+
48+
doc = addTitle( doc, "Title example 2", level = 1 )
49+
50+
# define some texts
51+
texts = c( "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
52+
, "In sit amet ipsum tellus. Vivamus dignissim arcu sit amet faucibus auctor."
53+
, "Quisque dictum tristique ligula."
54+
)
55+
56+
# add texts with stylename BulletList
57+
doc = addParagraph( doc, value = texts, stylename="BulletList" )
58+
59+
doc = addTitle( doc, "Title example 3", level = 1 )
60+
# "My tailor is rich" with formatting on some words
61+
pot1 = pot("My tailor", textProperties(color = "red" )
62+
) + " is " + pot("rich", textProperties( font.weight = "bold" ) )
63+
# "Cats and dogs" with formatting on some words
64+
pot2 = pot("Cats", textProperties(color = "red" )
65+
) + " and " + pot("dogs", textProperties( color = "blue" ) )
66+
67+
# create a set of paragraphs made of pot1 and pot2
4868
my.pars = set_of_paragraphs( pot1, pot2 )
4969

50-
# used style is "BulletList" so that paragraphs will be preceded by bullet points
51-
# ("BulletList" is an existing style in the defaut template docx of the package)
52-
doc = addParagraph(doc, my.pars, "BulletList");
70+
# Add my.pars into the document doc
71+
doc = addParagraph(doc, my.pars, stylename = "Normal" )
5372

54-
writeDoc( doc, "addParagraph_example.docx" )
73+
# Write the object
74+
writeDoc( doc, file = doc.filename )
5575
#STOP_TAG_TEST
5676
}
5777
\seealso{

0 commit comments

Comments
 (0)