Skip to content

Commit

Permalink
doc: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgohel committed Mar 4, 2024
1 parent 5ccef40 commit f3e2860
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 31 deletions.
51 changes: 34 additions & 17 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ output:
[![version](https://www.r-pkg.org/badges/version/flextable)](https://CRAN.R-project.org/package=flextable)
![Active](https://www.repostatus.org/badges/latest/active.svg)

```{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()
```


Expand All @@ -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
Expand All @@ -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


Expand Down
48 changes: 34 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```

<img src="man/figures/README-mtcars-dataset-1.png" width="792" />

``` 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")
```

<img src="man/figures/README-mtcars-dataset-2.png" width="792" />

``` r
ggplot2::diamonds[, c("cut", "carat", "price", "clarity", "table")] |>
summarizor(by = c("cut")) |>
as_flextable(spread_first_col = TRUE)
```

<img src="man/figures/README-diamonds-dataset-1.png" width="740" />

## Installation

``` r
Expand Down
Binary file added man/figures/README-diamonds-dataset-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/README-mtcars-dataset-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/README-mtcars-dataset-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f3e2860

Please sign in to comment.