Skip to content

Commit f3e2860

Browse files
committed
doc: update README
1 parent 5ccef40 commit f3e2860

File tree

5 files changed

+68
-31
lines changed

5 files changed

+68
-31
lines changed

README.Rmd

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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}
1515
knitr::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,
3136
such 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-
4838
Tables can be embedded within HTML, PDF, Word and PowerPoint documents
4939
from R Markdown documents and within RTF or Microsoft Word or PowerPoint
5040
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:
7060
The package also offers a set of high-level functions that allow tabular
7161
reporting 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

README.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@ it possible to build any table for publication from a `data.frame` and
1616
provides sugar function `as_flextable()` to convert several R objects to
1717
a flextable, such as an object return from `table()` or a model.
1818

19-
``` r
20-
set_flextable_defaults(
21-
font.family = "Arial", font.size = 10,
22-
border.color = "gray")
23-
24-
flextable(head(cars)) %>%
25-
bold(part = "header") %>%
26-
add_footer_lines("The 'cars' dataset")
27-
28-
ggplot2::diamonds |>
29-
with(table(cut, color)) |>
30-
as_flextable()
31-
```
32-
3319
Tables can be embedded within HTML, PDF, Word and PowerPoint documents
3420
from R Markdown documents and within RTF or Microsoft Word or PowerPoint
3521
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
5642
reporting of statistical models and the creation of complex cross
5743
tabulations.
5844

45+
## Examples
46+
47+
``` r
48+
library(flextable)
49+
set_flextable_defaults(
50+
font.family = "Arial", font.size = 10,
51+
border.color = "gray", big.mark = "")
52+
53+
ft <- flextable(head(mtcars)) |>
54+
bold(part = "header")
55+
ft
56+
```
57+
58+
<img src="man/figures/README-mtcars-dataset-1.png" width="792" />
59+
60+
``` r
61+
62+
ft |>
63+
highlight(i = ~ mpg < 22, j = "disp", color = "#ffe842") |>
64+
bg(j = c("hp", "drat", "wt"),
65+
bg = scales::col_quantile(palette = c("wheat", "red"), domain =NULL)) |>
66+
add_footer_lines("The 'mtcars' dataset")
67+
```
68+
69+
<img src="man/figures/README-mtcars-dataset-2.png" width="792" />
70+
71+
``` r
72+
ggplot2::diamonds[, c("cut", "carat", "price", "clarity", "table")] |>
73+
summarizor(by = c("cut")) |>
74+
as_flextable(spread_first_col = TRUE)
75+
```
76+
77+
<img src="man/figures/README-diamonds-dataset-1.png" width="740" />
78+
5979
## Installation
6080

6181
``` r
50.1 KB
Loading
11.5 KB
Loading
15 KB
Loading

0 commit comments

Comments
 (0)