diff --git a/README.Rmd b/README.Rmd
index e3224279..efe31092 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -11,12 +11,17 @@ output:
[](https://CRAN.R-project.org/package=flextable)

-```{r, echo = FALSE}
+```{r include=FALSE}
knitr::opts_chunk$set(
message = FALSE,
collapse = TRUE,
- comment = "#>"
+ comment = "#>",
+ fig.path = "man/figures/README-",
+ dev = "ragg_png",
+ dpi = 200
)
+library(gdtools)
+register_liberationsans()
```
@@ -30,21 +35,6 @@ publication from a `data.frame` and provides sugar function
`as_flextable()` to convert several R objects to a flextable,
such as an object return from `table()` or a model.
-```{r eval=FALSE}
-set_flextable_defaults(
- font.family = "Arial", font.size = 10,
- border.color = "gray")
-
-flextable(head(cars)) %>%
- bold(part = "header") %>%
- add_footer_lines("The 'cars' dataset")
-
-ggplot2::diamonds |>
- with(table(cut, color)) |>
- as_flextable()
-```
-
-
Tables can be embedded within HTML, PDF, Word and PowerPoint documents
from R Markdown documents and within RTF or Microsoft Word or PowerPoint
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:
The package also offers a set of high-level functions that allow tabular
reporting of statistical models and the creation of complex cross tabulations.
+## Examples
+
+
+```{r 'mtcars-dataset', message=FALSE, warning=FALSE}
+library(flextable)
+set_flextable_defaults(
+ font.family = "Arial", font.size = 10,
+ border.color = "gray", big.mark = "")
+
+ft <- flextable(head(mtcars)) |>
+ bold(part = "header")
+ft
+
+ft |>
+ highlight(i = ~ mpg < 22, j = "disp", color = "#ffe842") |>
+ bg(j = c("hp", "drat", "wt"),
+ bg = scales::col_quantile(palette = c("wheat", "red"), domain =NULL)) |>
+ add_footer_lines("The 'mtcars' dataset")
+```
+
+
+```{r 'diamonds-dataset'}
+ggplot2::diamonds[, c("cut", "carat", "price", "clarity", "table")] |>
+ summarizor(by = c("cut")) |>
+ as_flextable(spread_first_col = TRUE)
+```
+
## Installation
diff --git a/README.md b/README.md
index eff66a87..dbd19bb1 100644
--- a/README.md
+++ b/README.md
@@ -16,20 +16,6 @@ it possible to build any table for publication from a `data.frame` and
provides sugar function `as_flextable()` to convert several R objects to
a flextable, such as an object return from `table()` or a model.
-``` r
-set_flextable_defaults(
- font.family = "Arial", font.size = 10,
- border.color = "gray")
-
-flextable(head(cars)) %>%
- bold(part = "header") %>%
- add_footer_lines("The 'cars' dataset")
-
-ggplot2::diamonds |>
- with(table(cut, color)) |>
- as_flextable()
-```
-
Tables can be embedded within HTML, PDF, Word and PowerPoint documents
from R Markdown documents and within RTF or Microsoft Word or PowerPoint
documents with package officer. Tables can also be rendered as R plots
@@ -56,6 +42,40 @@ The package also offers a set of high-level functions that allow tabular
reporting of statistical models and the creation of complex cross
tabulations.
+## Examples
+
+``` r
+library(flextable)
+set_flextable_defaults(
+ font.family = "Arial", font.size = 10,
+ border.color = "gray", big.mark = "")
+
+ft <- flextable(head(mtcars)) |>
+ bold(part = "header")
+ft
+```
+
+
+
+``` r
+
+ft |>
+ highlight(i = ~ mpg < 22, j = "disp", color = "#ffe842") |>
+ bg(j = c("hp", "drat", "wt"),
+ bg = scales::col_quantile(palette = c("wheat", "red"), domain =NULL)) |>
+ add_footer_lines("The 'mtcars' dataset")
+```
+
+
+
+``` r
+ggplot2::diamonds[, c("cut", "carat", "price", "clarity", "table")] |>
+ summarizor(by = c("cut")) |>
+ as_flextable(spread_first_col = TRUE)
+```
+
+
+
## Installation
``` r
diff --git a/man/figures/README-diamonds-dataset-1.png b/man/figures/README-diamonds-dataset-1.png
new file mode 100644
index 00000000..0817631a
Binary files /dev/null and b/man/figures/README-diamonds-dataset-1.png differ
diff --git a/man/figures/README-mtcars-dataset-1.png b/man/figures/README-mtcars-dataset-1.png
new file mode 100644
index 00000000..5b5af42c
Binary files /dev/null and b/man/figures/README-mtcars-dataset-1.png differ
diff --git a/man/figures/README-mtcars-dataset-2.png b/man/figures/README-mtcars-dataset-2.png
new file mode 100644
index 00000000..5d5b2292
Binary files /dev/null and b/man/figures/README-mtcars-dataset-2.png differ