-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
README.Rmd
96 lines (74 loc) · 1.93 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{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
<!-- badges: start -->
[![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)
<!-- badges: end -->
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()
```