knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-"
)

ggpage

Travis build status AppVeyor build status Coverage status CRAN status

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 with:

install.packages("ggpage")

or you can install the developmental version of ggpage from github with:

# install.packages("devtools")
devtools::install_github("EmilHvitfeldt/ggpage")

Example

The package includes The Tinder-box by H.C. Andersen for examples.

library(tidyverse)
library(ggpage)

head(tinderbox, 10)

The basic workflow with ggpage is using either

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".

ggpage_quick(tinderbox)

# Also pipeable
# tinderbox %>% ggpage_quick()

The same result would be achieved by using

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

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


EmilHvitfeldt/ggpage documentation built on June 15, 2019, 8:31 a.m.