@@ -11,12 +11,17 @@ output:
1111[ ![ version] ( https://www.r-pkg.org/badges/version/flextable )] ( https://CRAN.R-project.org/package=flextable )
1212![ Active] ( https://www.repostatus.org/badges/latest/active.svg )
1313
14- ``` {r, echo = FALSE}
14+ ``` {r include= FALSE}
1515knitr::opts_chunk$set(
1616 message = FALSE,
1717 collapse = TRUE,
18- comment = "#>"
18+ comment = "#>",
19+ fig.path = "man/figures/README-",
20+ dev = "ragg_png",
21+ dpi = 200
1922)
23+ library(gdtools)
24+ register_liberationsans()
2025```
2126
2227
@@ -30,21 +35,6 @@ publication from a `data.frame` and provides sugar function
3035` as_flextable() ` to convert several R objects to a flextable,
3136such as an object return from ` table() ` or a model.
3237
33- ``` {r eval=FALSE}
34- set_flextable_defaults(
35- font.family = "Arial", font.size = 10,
36- border.color = "gray")
37-
38- flextable(head(cars)) %>%
39- bold(part = "header") %>%
40- add_footer_lines("The 'cars' dataset")
41-
42- ggplot2::diamonds |>
43- with(table(cut, color)) |>
44- as_flextable()
45- ```
46-
47-
4838Tables can be embedded within HTML, PDF, Word and PowerPoint documents
4939from R Markdown documents and within RTF or Microsoft Word or PowerPoint
5040documents with package officer. Tables can also be rendered as R plots
@@ -70,6 +60,33 @@ their layout. The package provides functions that give control over:
7060The package also offers a set of high-level functions that allow tabular
7161reporting of statistical models and the creation of complex cross tabulations.
7262
63+ ## Examples
64+
65+
66+ ``` {r 'mtcars-dataset', message=FALSE, warning=FALSE}
67+ library(flextable)
68+ set_flextable_defaults(
69+ font.family = "Arial", font.size = 10,
70+ border.color = "gray", big.mark = "")
71+
72+ ft <- flextable(head(mtcars)) |>
73+ bold(part = "header")
74+ ft
75+
76+ ft |>
77+ highlight(i = ~ mpg < 22, j = "disp", color = "#ffe842") |>
78+ bg(j = c("hp", "drat", "wt"),
79+ bg = scales::col_quantile(palette = c("wheat", "red"), domain =NULL)) |>
80+ add_footer_lines("The 'mtcars' dataset")
81+ ```
82+
83+
84+ ``` {r 'diamonds-dataset'}
85+ ggplot2::diamonds[, c("cut", "carat", "price", "clarity", "table")] |>
86+ summarizor(by = c("cut")) |>
87+ as_flextable(spread_first_col = TRUE)
88+ ```
89+
7390## Installation
7491
7592
0 commit comments