-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
56 lines (40 loc) · 3.28 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
[](http://www.repostatus.org/#active) [](https://travis-ci.org/gederajeg/scapr) [](https://ci.appveyor.com/project/gederajeg/scapr) [](https://codecov.io/github/gederajeg/scapr?branch=master) [](https://zenodo.org/badge/latestdoi/128873321)
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# scapr
The goal of `scapr` is to provide a set of functions that wrap over the HTML-tag for generating <span style = "font-variant:small-caps;">small capitals</span> strings. I designed this package to help me with the writing of my thesis in R Markdown that deals with lots of small-capitalisation of words to be rendered into MS Word output. The package aims to save time and, most importantly, prevent typo in writing the small capital tag (i.e., `<span style = "font-variant:small-caps;">a small capital string</span>`) over and over again in the R Markdown (cf. Yihui Xie's chapter in [Bookdown](https://bookdown.org/yihui/bookdown/markdown-syntax.html) about inline-formatting for small capital in R markdown). The `scapr` package can be seen as a complement to the [`lettercase`](https://cran.r-project.org/package=lettercase) R package by Christopher Brown that does not include small capital feature.
## Installation
You can install `scapr` from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("gederajeg/scapr")
```
## Example
```{r load-package, message = FALSE, warning = FALSE}
library(scapr)
library(dplyr)
```
The main function in the package is `scaps()`. It can be used as an inline R code in R Markdown as follows: `` `r knitr::inline_expr('scaps("happiness")')` ``. It will then turn "happiness" into "`r scaps("happiness")`". The alternative is to "pipe" `scaps()` after the target string: `` `r knitr::inline_expr('"happiness" %>% scaps()')` ``, which generates `r "happiness" %>% scaps()`. `scaps()` can also be used to modify strings in a data frame to be printed as table with `knitr` package:
```{r scaps-in-table}
# create the tibble/data_frame
df <- dplyr::tibble(concept = scaps(c("time", "emotion")),
freq = c(45, 53))
# print with knitr
knitr::kable(df, caption = "A table with small-capitalised strings")
```
There are three other functions in the package for different font-face types of the small capital string. They are `scaps_italics()` (for `r scaps_italics("italicised small captial string")`), `scaps_bold()` (for `r scaps_bold("boldfaced small capital string")`) and `scaps_bolditalics()` (for both `r scaps_bolditalics("italicised and boldfaced small capital string")`).
## Session info
```{r}
devtools::session_info()
rmarkdown::pandoc_version()
```