8686# ' value for `build_stage` then the entire build for the table body (i.e., up
8787# ' to and including the `"footnotes_attached"` stage) will be performed before
8888# ' returning the data frame.
89- # '
89+ # '
9090# ' @param incl_hidden_cols *Should hidden columns be included?*
91- # '
91+ # '
9292# ' `scalar<logical>` // *default:* `FALSE`
93- # '
93+ # '
9494# ' Certain columns may be hidden from final display via [cols_hide()]. By
9595# ' default, those columns won't be part of the extracted data frame. However,
9696# ' we can choose to include them by using `incl_hidden_cols = TRUE`.
97- # '
97+ # '
9898# ' @param incl_stub_cols *Should stub columns be included?*
99- # '
99+ # '
100100# ' `scalar<logical>` // *default:* `TRUE`
101- # '
101+ # '
102102# ' Any stub columns in the **gt** object (which may consist of a grouping
103103# ' column and a column for row labels) are included in the extracted data for
104104# ' clarity but clearly marked with the names `"::group_id::"` and
114114# ' `"html"` (the default), `"latex"`, `"rtf"`, or `"word"`.
115115# '
116116# ' @return A data frame or tibble object containing the table body.
117- # '
117+ # '
118118# ' @section Examples:
119119# '
120120# ' Use a modified version of [`sp500`] the dataset to create a **gt** table with
135135# ' fmt_date(columns = date, date_style = "day_month_year") |>
136136# ' fmt_currency(columns = c(open, high, low, close)) |>
137137# ' cols_hide(columns = c(high, low))
138- # '
138+ # '
139139# ' ```
140- # '
140+ # '
141141# ' ```r
142142# ' gt_tbl
143143# ' ```
144- # '
144+ # '
145145# ' \if{html}{\out{
146146# ' `r man_get_image_tag(file = "man_extract_body_1.png")`
147147# ' }}
148- # '
148+ # '
149149# ' Using `extract_body()` on the **gt** object (`gt_tbl`) will provide us with
150150# ' a tibble that contains the fully built data cells for the `output` context
151151# ' (in this case, `"html"`).
152- # '
152+ # '
153153# ' ```{r}
154154# ' extract_body(gt_tbl)
155155# ' ```
156- # '
156+ # '
157157# ' To provide us with a better frame of reference, the grouping and row label
158158# ' values are provided as the first columns in the returned output. We could
159- # ' suppress those in the output by setting `incl_stub_cols = FALSE`.
160- # '
159+ # ' suppress those in the output by setting `incl_stub_cols = FALSE`.
160+ # '
161161# ' ```{r}
162162# ' extract_body(gt_tbl, incl_stub_cols = FALSE)
163163# ' ```
164- # '
164+ # '
165165# ' The `high` and `low` columns were hidden via [`cols_hide()`] and so they
166166# ' won't be shown in the returned data unless we use `incl_hidden_cols = TRUE`.
167- # '
167+ # '
168168# ' ```{r}
169169# ' extract_body(
170170# ' gt_tbl,
@@ -195,7 +195,7 @@ extract_body <- function(
195195
196196 # If `build_stage` is given a keyword value, check that value is valid
197197 if (! is.null(build_stage )) {
198-
198+
199199 rlang :: arg_match0(
200200 build_stage ,
201201 values = c(
@@ -211,15 +211,15 @@ extract_body <- function(
211211 output ,
212212 values = c(" html" , " latex" , " rtf" , " word" , " grid" )
213213 )
214-
214+
215215 rlang :: check_dots_empty()
216216
217- # Generate vector of columns to include in output
217+ # Generate vector of columns to include in output
218218 if (isTRUE(incl_hidden_cols )) {
219219
220220 boxhead_df <- dt_boxhead_get(data = data )
221221
222- included_cols <-
222+ included_cols <-
223223 boxhead_df $ var [boxhead_df $ type %in% c(" default" , " hidden" )]
224224
225225 } else {
@@ -246,98 +246,98 @@ extract_body <- function(
246246 }
247247
248248 data <- dt_body_build(data = data )
249-
249+
250250 if (identical(build_stage , " init" )) {
251-
252- out_df <-
251+
252+ out_df <-
253253 assemble_body_extract(
254254 data = data ,
255255 included_cols = included_cols ,
256256 incl_stub_cols = incl_stub_cols ,
257257 group_col = group_col ,
258258 rowname_col = rowname_col
259259 )
260-
260+
261261 return (out_df )
262262 }
263263
264264 data <- render_formats(data = data , context = output )
265265
266266 if (identical(build_stage , " fmt_applied" )) {
267-
268- out_df <-
267+
268+ out_df <-
269269 assemble_body_extract(
270270 data = data ,
271271 included_cols = included_cols ,
272272 incl_stub_cols = incl_stub_cols ,
273273 group_col = group_col ,
274274 rowname_col = rowname_col
275275 )
276-
276+
277277 return (out_df )
278278 }
279279
280280 data <- render_substitutions(data = data , context = output )
281281
282282 if (identical(build_stage , " sub_applied" )) {
283-
284- out_df <-
283+
284+ out_df <-
285285 assemble_body_extract(
286286 data = data ,
287287 included_cols = included_cols ,
288288 incl_stub_cols = incl_stub_cols ,
289289 group_col = group_col ,
290290 rowname_col = rowname_col
291291 )
292-
292+
293293 return (out_df )
294294 }
295295
296296 data <- migrate_unformatted_to_output(data = data , context = output )
297297
298298 if (identical(build_stage , " unfmt_included" )) {
299-
300- out_df <-
299+
300+ out_df <-
301301 assemble_body_extract(
302302 data = data ,
303303 included_cols = included_cols ,
304304 incl_stub_cols = incl_stub_cols ,
305305 group_col = group_col ,
306306 rowname_col = rowname_col
307307 )
308-
308+
309309 return (out_df )
310310 }
311311
312312 data <- perform_col_merge(data = data , context = output )
313313
314314 if (identical(build_stage , " cols_merged" )) {
315-
316- out_df <-
315+
316+ out_df <-
317317 assemble_body_extract(
318318 data = data ,
319319 included_cols = included_cols ,
320320 incl_stub_cols = incl_stub_cols ,
321321 group_col = group_col ,
322322 rowname_col = rowname_col
323323 )
324-
324+
325325 return (out_df )
326326 }
327327
328328 data <- dt_body_reassemble(data = data )
329329
330330 if (identical(build_stage , " body_reassembled" )) {
331-
332- out_df <-
331+
332+ out_df <-
333333 assemble_body_extract(
334334 data = data ,
335335 included_cols = included_cols ,
336336 incl_stub_cols = incl_stub_cols ,
337337 group_col = group_col ,
338338 rowname_col = rowname_col
339339 )
340-
340+
341341 return (out_df )
342342 }
343343
@@ -349,15 +349,15 @@ extract_body <- function(
349349
350350 if (identical(build_stage , " text_transformed" )) {
351351
352- out_df <-
352+ out_df <-
353353 assemble_body_extract(
354354 data = data ,
355355 included_cols = included_cols ,
356356 incl_stub_cols = incl_stub_cols ,
357357 group_col = group_col ,
358358 rowname_col = rowname_col
359359 )
360-
360+
361361 return (out_df )
362362 }
363363
@@ -372,9 +372,9 @@ extract_body <- function(
372372 data <- resolve_footnotes_styles(data = data , tbl_type = " footnotes" )
373373 data <- apply_footnotes_to_output(data = data , context = output )
374374
375- if (is.null(build_stage ) || identical(build_stage , " footnotes_attached" )) {
376-
377- out_df <-
375+ if (is.null(build_stage ) || identical(build_stage , " footnotes_attached" )) {
376+
377+ out_df <-
378378 assemble_body_extract(
379379 data = data ,
380380 included_cols = included_cols ,
@@ -394,21 +394,21 @@ assemble_body_extract <- function(
394394 group_col ,
395395 rowname_col
396396) {
397-
397+
398398 out_df <- data [[" _body" ]][, included_cols ]
399-
399+
400400 if (isTRUE(incl_stub_cols )) {
401-
401+
402402 if (! is.null(group_col )) {
403403 names(out_df )[names(out_df ) == group_col ] <- " ::group_id::"
404404 }
405-
405+
406406 if (! is.null(rowname_col )) {
407407 # ::rowname::
408408 names(out_df )[names(out_df ) == rowname_col ] <- rowname_col_private
409409 }
410410 }
411-
411+
412412 out_df
413413}
414414
@@ -618,7 +618,7 @@ extract_cells <- function(
618618 stop_if_not_gt_tbl(data = data )
619619
620620 # Ensure that `output` is matched correctly to one option
621- output <-
621+ output <-
622622 rlang :: arg_match0(
623623 output ,
624624 values = c(" auto" , " plain" , " html" , " latex" , " rtf" , " word" , " grid" )
0 commit comments