Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/atusy/ftExtra

Helper functions for the flextable package
https://github.com/atusy/ftExtra

Last synced: 20 days ago
JSON representation

Helper functions for the flextable package

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
library(knitr)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)

render_html <- function(x, options, ...) {
to <- tempfile(fileext = ".png")
knit_print(structure(
flextable::save_as_image(x, to, webshot = "webshot2"),
class = "webshot"
))
}

knitr::opts_chunk$set(
fig.path = "man/figures/"
)
```

# ftExtra

[![R-CMD-check](https://github.com/atusy/ftExtra/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/atusy/ftExtra/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/ftExtra)](https://CRAN.R-project.org/package=ftExtra)
![Downloads](https://cranlogs.r-pkg.org/badges/grand-total/ftExtra)
![Monthly downloads](https://cranlogs.r-pkg.org/badges/ftExtra)

The ftExtra package provides helper functions for the flextable package:

* `colformat_md` parses markdown texts in columns
* `span_header` makes multi-level headers
* and more!

## Installation

### from CRAN

``` r
install.packages("ftExtra")
```

### from GitHub

``` r
options(repos = c(atusy = 'https://atusy.r-universe.dev', getOption("repos")))
install.packages("ftExtra")
```

## Example

```{r example, results='hide'}
library(ftExtra)
```

### Parse markdown texts

```{r colformat_md, render = render_html}
data.frame(
x = c("**bold**", "*italic*"),
y = c("^superscript^", "~subscript~"),
z = c("***~ft~^Extra^** is*", "*Cool*"),
stringsAsFactors = FALSE
) %>%
flextable() %>%
colformat_md()
```

### Span headers

```{r span-header, render = render_html}
iris %>%
head() %>%
flextable() %>%
span_header()
```

### Group rows

```{r group-rows, render = render_html}
library(dplyr, warn.conflicts = FALSE)
iris %>%
group_by(Species) %>%
slice(1:2) %>%
flextable()
```