@@ -11,12 +11,17 @@ output:
11
11
[ ![ version] ( https://www.r-pkg.org/badges/version/flextable )] ( https://CRAN.R-project.org/package=flextable )
12
12
![ Active] ( https://www.repostatus.org/badges/latest/active.svg )
13
13
14
- ``` {r, echo = FALSE}
14
+ ``` {r include= FALSE}
15
15
knitr::opts_chunk$set(
16
16
message = FALSE,
17
17
collapse = TRUE,
18
- comment = "#>"
18
+ comment = "#>",
19
+ fig.path = "man/figures/README-",
20
+ dev = "ragg_png",
21
+ dpi = 200
19
22
)
23
+ library(gdtools)
24
+ register_liberationsans()
20
25
```
21
26
22
27
@@ -30,21 +35,6 @@ publication from a `data.frame` and provides sugar function
30
35
` as_flextable() ` to convert several R objects to a flextable,
31
36
such as an object return from ` table() ` or a model.
32
37
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
-
48
38
Tables can be embedded within HTML, PDF, Word and PowerPoint documents
49
39
from R Markdown documents and within RTF or Microsoft Word or PowerPoint
50
40
documents 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:
70
60
The package also offers a set of high-level functions that allow tabular
71
61
reporting of statistical models and the creation of complex cross tabulations.
72
62
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
+
73
90
## Installation
74
91
75
92
0 commit comments