Skip to content

Commit

Permalink
native pipe to magrittr pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Feb 2, 2024
1 parent 5d1965c commit 474e0de
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions tests/testthat/test-render_as_gtable.R
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
test_that("gt_tbls can be rendered as a gtable", {

table <- pizzaplace |>
dplyr::filter(type %in% c("classic", "veggie")) |>
dplyr::group_by(type, size) |>
table <- pizzaplace %>%
dplyr::filter(type %in% c("classic", "veggie")) %>%
dplyr::group_by(type, size) %>%
dplyr::summarize(
sold = dplyr::n(),
income = sum(price),
.groups = "drop"
) |>
gt(rowname_col = "size", groupname_col = "type") |>
tab_header(title = "Pizzas Sold in 2015") |>
fmt_integer(columns = sold) |>
fmt_currency(columns = income) |>
) %>%
gt(rowname_col = "size", groupname_col = "type") %>%
tab_header(title = "Pizzas Sold in 2015") %>%
fmt_integer(columns = sold) %>%
fmt_currency(columns = income) %>%
summary_rows(
fns = list(label = "All Sizes", fn = "sum"),
side = c("top"),
fmt = list(
~ fmt_integer(., columns = sold),
~ fmt_currency(., columns = income)
)
) |>
) %>%
tab_options(
summary_row.background.color = "gray95",
row_group.as_column = TRUE
) |>
) %>%
tab_stub_indent(
rows = everything(),
indent = 2
) |>
) %>%
grand_summary_rows(
columns = c("sold", "income"),
fns = list(Sum ~ sum(.)),
fmt = ~ fmt_number(.)
) |>
tab_caption("Here be caption text") |>
) %>%
tab_caption("Here be caption text") %>%
tab_spanner(
label = "Spanner",
columns = c("sold", "income")
) |>
tab_stubhead("Stubhead label") |>
tab_source_note("Source: the pizzaria") |>
) %>%
tab_stubhead("Stubhead label") %>%
tab_source_note("Source: the pizzaria") %>%
tab_footnote("Pineapples not included")

gtable <- render_as_gtable(table)
Expand Down

0 comments on commit 474e0de

Please sign in to comment.