-
Notifications
You must be signed in to change notification settings - Fork 12
/
README.Rmd
84 lines (61 loc) · 2.67 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
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# ggpage <img src='man/figures/logo.png' align="right" height="139" />
[![Travis build status](https://travis-ci.org/EmilHvitfeldt/ggpage.svg?branch=master)](https://travis-ci.org/EmilHvitfeldt/ggpage)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/EmilHvitfeldt/ggpage?branch=master&svg=true)](https://ci.appveyor.com/project/EmilHvitfeldt/ggpage)
[![Coverage status](https://codecov.io/gh/EmilHvitfeldt/ggpage/branch/master/graph/badge.svg)](https://codecov.io/github/EmilHvitfeldt/ggpage?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/ggpage)](https://cran.r-project.org/package=ggpage)
**ggpage** is a package to create pagestyled visualizations of text based data. It uses ggplot2 and final returns are ggplot2 objects.
## Version 0.2.0
In this new version I have worked to include a lot of use cases that wasn't available in the first version. These new elements are previewed in the vignette.
## Installation
You can install the released version of **ggpage** from [CRAN](https://cran.r-project.org/) with:
```{r eval = FALSE}
install.packages("ggpage")
```
or you can install the developmental version of **ggpage** from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("EmilHvitfeldt/ggpage")
```
## Example
The package includes The Tinder-box by H.C. Andersen for examples.
```{r message=FALSE}
library(tidyverse)
library(ggpage)
head(tinderbox, 10)
```
The basic workflow with **ggpage** is using either
- `ggpage_quick` for a quick one function call plot or,
- combining `ggpage_build` and `ggpage_plot` to do analysis (NLP for example) before the final plot is produced.
For a simple demonstration we apply `ggpage_quick` to our `tinderbox` object. It is important that the data.frame that is used have the text in a column named "text".
```{r}
ggpage_quick(tinderbox)
# Also pipeable
# tinderbox %>% ggpage_quick()
```
The same result would be achieved by using
```{r eval=FALSE}
tinderbox %>%
ggpage_build() %>%
ggpage_plot()
```
But this approach allows us to introduce more code between `ggpage_build` and `ggpage_plot` giving us multiple more ways to enhance the plots
```{r}
tinderbox %>%
ggpage_build() %>%
mutate(long_word = stringr::str_length(word) > 8) %>%
ggpage_plot(aes(fill = long_word)) +
labs(title = "Longer words throughout The Tinder-box") +
scale_fill_manual(values = c("grey70", "blue"),
labels = c("8 or less", "9 or more"),
name = "Word length")
```