zzawadz / customLayout

Compare 2acd12c ... +3 ... 414b1b5

Coverage Reach

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -1,4 +1,3 @@
Loading
1 -
2 1
#' Split a selected field from layout using a schema from another layout.
3 2
#'
4 3
#' @param lay a Layout object.
@@ -7,6 +6,9 @@
Loading
7 6
#'
8 7
#' @export
9 8
#' @rdname lay_split_field
9 +
#' 
10 +
#' @return a new Layout object.
11 +
#' 
10 12
#' @examples
11 13
#' 
12 14
#' l1 <- lay_new(matrix(c(1:4), ncol = 2), widths = c(4, 1))

@@ -5,6 +5,7 @@
Loading
5 5
#'
6 6
#' @export
7 7
#' 
8 +
#' @return Invisibly return input \code{x}.
8 9
#' @seealso lay_new lay_show
9 10
#' 
10 11
#' @examples
@@ -50,12 +51,26 @@
Loading
50 51
#' @param widths a vector of values for the relative heights of rows in mat.
51 52
#' @param heights a vector of values for the relative heights of rows in mat.
52 53
#' 
54 +
#' 
55 +
#' @details 
56 +
#' 
57 +
#' This function creates a new \code{CustomLayout} object which contains the information about all the fields and their relative sizes.
58 +
#' 
59 +
#' By combining multiple \code{CustomLayout} objects you can create more complicated layouts for your plots.
60 +
#' 
61 +
#' This object is an alternative to \code{\link{layout}} function.
62 +
#' 
63 +
#' @seealso \code{\link{lay_bind_col}}, \code{\link{lay_bind_row}}, \code{\link{lay_set}}.
64 +
#' 
65 +
#' @return \code{CustomLayout} object.
66 +
#' 
67 +
#' 
53 68
#' @export
54 69
#' @rdname lay_new
55 70
#' @examples
56 71
#' library(customLayout)
57 72
#' set.seed(123)
58 -
#' par(mar = c(3, 2, 2, 1))
73 +
#' oldpar <- par(mar = c(3, 2, 2, 1))
59 74
#' 
60 75
#' # Prepare layout
61 76
#' lay  <- lay_new(matrix(1:4, nc = 2),
@@ -74,6 +89,8 @@
Loading
74 89
#' pie(c(3, 2, 7), col = 2:4 + 3)
75 90
#' pie(c(5, 4, 2), col = 2:4 + 6)
76 91
#' 
92 +
#' par(oldpar)
93 +
#' 
77 94
lay_new <- function(mat, widths = NULL, heights = NULL)
78 95
{
79 96
  if(!is.matrix(mat)) mat <- matrix(mat)
@@ -118,6 +135,7 @@
Loading
118 135
#' @param layout object of class Layout.
119 136
#' 
120 137
#' @export
138 +
#' @return Returns the number of figures in layout.
121 139
#' @rdname lay_set
122 140
#' @examples
123 141
#' 
@@ -146,21 +164,24 @@
Loading
146 164
  lay_set(layout)
147 165
}
148 166
149 -
#' Take two Layout objects and combine by rows.
167 +
#' Take two CustomLayout objects and combine by rows.
150 168
#' 
151 -
#' @param x object of class Layout
152 -
#' @param y object of class Layout
169 +
#' @param x object of class CustomLayout.
170 +
#' @param y object of class CustomLayout.
153 171
#' @param widths a vector with relative widths used in combining 
154 172
#'                the x and y layouts.
155 173
#' @param addmax if true (default) the ids of the plots in the second 
156 174
#'               layout will be shifted by the number of plots in 
157 175
#'               the first layout.
158 176
#'
159 177
#' @rdname lay_bind_col
178 +
#' 
179 +
#' @return \code{CustomLayout} object created from combining two CustomLayout.
180 +
#' 
160 181
#' @export
161 182
#' @examples
162 -
#' l1 = lay_new(matrix(c(1:2),ncol = 2),widths=c(4,1))
163 -
#' l2 = lay_new(matrix(c(1:4),ncol = 2),widths=c(1,1))
183 +
#' l1 = lay_new(matrix(c(1:2), ncol = 2),widths=c(4,1))
184 +
#' l2 = lay_new(matrix(c(1:4), ncol = 2),widths=c(1,1))
164 185
#' lb = lay_bind_col(l1,l2)
165 186
#' lay_show(lb)
166 187
#' 
@@ -214,17 +235,20 @@
Loading
214 235
  lay_bind_col(x, y, widths, addmax)
215 236
}
216 237
217 -
#' Take two Layout objects and combine by rows.
238 +
#' Take two CustomLayout objects and combine by rows.
218 239
#' 
219 -
#' @param x object of class Layout
220 -
#' @param y object of class Layout
240 +
#' @param x object of class CustomLayout.
241 +
#' @param y object of class CustomLayout.
221 242
#' @param heights a vector with relative heights used in combining 
222 243
#'                the x and y layouts.
223 244
#' @param addmax if true (default) the ids of the plots in the second 
224 245
#'               layout will be shifted by the number of plots in 
225 246
#'               the first layout.
226 247
#' 
227 248
#' @rdname lay_bind_row
249 +
#' 
250 +
#' @return \code{CustomLayout} object created from combining two CustomLayout.
251 +
#' 
228 252
#' @export
229 253
#' @examples
230 254
#' l1 = lay_new(matrix(c(1:2),ncol = 2),widths=c(4,1))
@@ -282,12 +306,15 @@
Loading
282 306
  .Deprecated("lay_bind_row")
283 307
  lay_bind_row(x, y, heights, addmax)
284 308
}
309 +
285 310
#' Use Layout object with grid graphics.
286 311
#'
287 312
#' @param grobs list of grobs.
288 313
#' @param lay a Layout object.
289 314
#' @param ... other parameters passed to \code{\link{grid.arrange}}.
290 315
#'
316 +
#' @return \code{gtable} object containing multiple graphs. See \code{\link{grid.arrange}}.
317 +
#'
291 318
#' @export
292 319
#' @rdname lay_grid
293 320
#' @examples

@@ -5,6 +5,8 @@
Loading
5 5
#'
6 6
#' @export
7 7
#' 
8 +
#' @return Invisibly returns \code{x}.
9 +
#' 
8 10
#' @seealso lay_new lay_show phl_layout
9 11
#' 
10 12
#' @examples
@@ -37,6 +39,7 @@
Loading
37 39
  print_attr(att, "slideHeight")
38 40
  print_attr(att, "margins")
39 41
  print_attr(att, "innerMargins")
42 +
  invisible(x)
40 43
}
41 44
42 45
#' Create layout for the officer PowerPoint slide.
@@ -151,14 +154,16 @@
Loading
151 154
  x
152 155
}
153 156
154 -
#' add ggplot into layout placeholder
157 +
#' Add ggplot into layout placeholder
155 158
#'
156 159
#' @param x rpptx object
157 160
#' @param olay an OfficerLayout object created using \code{\link{phl_layout}}
158 161
#' @param id an single integer with an id of the placeholder from \code{olay} object.
159 162
#' @param value a ggplot object
160 163
#' @param ... other arguments passed to \code{\link{ph_with}}
161 164
#'
165 +
#' @return \code{rpptx} object which represents PowerPoint presentation in \code{officer}. The returned object contains a new element on the slide.
166 +
#'
162 167
#' @export
163 168
#' @importFrom officer ph_location external_img ph_location_template ph_with
164 169
#' @importFrom rvg dml
@@ -176,7 +181,7 @@
Loading
176 181
  )
177 182
}
178 183
179 -
#' add a plot as vector graphics into layout placeholder
184 +
#' Add a plot as vector graphics into layout placeholder
180 185
#'
181 186
#' @param x rpptx object
182 187
#' @param olay an OfficerLayout object created using \code{\link{phl_layout}}
@@ -185,6 +190,7 @@
Loading
185 190
#' @param ggobj ggplot objet to print. Argument code will be ignored if this argument is supplied.
186 191
#' @param ... other arguments passed to \code{\link{dml_pptx}}
187 192
#'
193 +
#' @return \code{rpptx} object which represents PowerPoint presentation in \code{officer}. The returned object contains a new element on the slide.
188 194
#' @export
189 195
#' 
190 196
phl_with_vg <- function(x, olay, id, code, ggobj = NULL, ...) {
@@ -202,7 +208,7 @@
Loading
202 208
}
203 209
204 210
205 -
#' add plot into layout placeholder
211 +
#' Add plot into layout placeholder
206 212
#'
207 213
#' @param x rpptx object
208 214
#' @param olay an OfficerLayout object created using \code{\link{phl_layout}}
@@ -211,6 +217,7 @@
Loading
211 217
#' @param res The nominal resolution in ppi which will be recorded in the bitmap file. Default 300. See \code{res} parameter in \code{\link{png}}.
212 218
#' @param ... other arguments passed to \code{\link{png}} function.
213 219
#'
220 +
#' @return \code{rpptx} object which represents PowerPoint presentation in \code{officer}. The returned object contains a new element on the slide.
214 221
#' @export
215 222
#' 
216 223
phl_with_plot <- function(x, olay, id, plotFnc, res = 300, ...) {
@@ -244,7 +251,7 @@
Loading
244 251
#' @param str text to add.
245 252
#' @param type type of the text placeholder. See \code{\link{ph_add_text}} for more details.
246 253
#' @param ... other arguments passed to \code{\link{ph_add_text}}.
247 -
#'
254 +
#' @return \code{rpptx} object which represents PowerPoint presentation in \code{officer}. The returned object contains a new element on the slide.
248 255
#' @export
249 256
#' @importFrom officer slide_summary
250 257
phl_with_text <- function(x, olay, id, str, type = "title", ...) {
@@ -272,7 +279,7 @@
Loading
272 279
#' @param id an single integer with an id of the placeholder from \code{olay} object.
273 280
#' @param value a data.frame
274 281
#' @param ... other arguments passed to \code{\link{ph_with}}
275 -
#'
282 +
#' @return \code{rpptx} object which represents PowerPoint presentation in \code{officer}. The returned object contains a new element on the slide.
276 283
#' @export
277 284
#' 
278 285
phl_with_table <- function(x, olay, id, value, ...) {

@@ -105,7 +105,7 @@
Loading
105 105
  flTable
106 106
}
107 107
108 -
#' add flextable into layout placeholder
108 +
#' Add flextable into layout placeholder
109 109
#'
110 110
#' @param x rpptx object
111 111
#' @param olay an OfficerLayout object created using \code{\link{phl_layout}}.
@@ -114,6 +114,8 @@
Loading
114 114
#'    Possibly the result of the \code{\link{phl_adjust_table}}
115 115
#'
116 116
#' @export
117 +
#' 
118 +
#' @return \code{rpptx} object which represents PowerPoint presentation in \code{officer}. The returned object contains a new element on the slide.
117 119
#'
118 120
#' @examples
119 121
#' 

@@ -48,6 +48,8 @@
Loading
48 48
#'
49 49
#' @export
50 50
#' @rdname lay_show
51 +
#' 
52 +
#' @return No return value, called for side effects.
51 53
#'
52 54
#' @examples
53 55
#' 

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
R 0.02% 91.43%
Project Totals (7 files) 91.43%
Loading