├── .Rbuildignore ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── NEWS.md ├── R ├── data.R ├── ggpage_build.R ├── ggpage_plot.R ├── ggpage_quick.R ├── global.R ├── nest_paragraphs.R ├── utils-pipe.R └── utils.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── appveyor.yml ├── codecov.yml ├── cran-comments.md ├── data-raw └── tinderbow_paragraph.R ├── data ├── tinderbox.rda └── tinderbox_paragraph.rda ├── docs ├── LICENSE-text.html ├── apple-touch-icon-120x120.png ├── apple-touch-icon-152x152.png ├── apple-touch-icon-180x180.png ├── apple-touch-icon-60x60.png ├── apple-touch-icon-76x76.png ├── apple-touch-icon.png ├── articles │ ├── different-features.html │ ├── different-features_files │ │ └── figure-html │ │ │ ├── unnamed-chunk-1-1.png │ │ │ ├── unnamed-chunk-1-2.png │ │ │ ├── unnamed-chunk-1-3.png │ │ │ ├── unnamed-chunk-1-4.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ ├── unnamed-chunk-5-1.png │ │ │ ├── unnamed-chunk-5-2.png │ │ │ ├── unnamed-chunk-5-3.png │ │ │ ├── unnamed-chunk-5-4.png │ │ │ ├── unnamed-chunk-5-5.png │ │ │ ├── unnamed-chunk-5-6.png │ │ │ ├── unnamed-chunk-5-7.png │ │ │ ├── unnamed-chunk-5-8.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ ├── unnamed-chunk-7-1.png │ │ │ └── unnamed-chunk-7-2.png │ └── index.html ├── authors.html ├── docsearch.css ├── docsearch.js ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon.ico ├── index.html ├── link.svg ├── logo.png ├── news │ └── index.html ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml └── reference │ ├── break_help.html │ ├── figures │ ├── README-readmegif-1.gif │ ├── README-unnamed-chunk-3-1.png │ ├── README-unnamed-chunk-4-1.png │ ├── README-unnamed-chunk-5-1.png │ ├── README-unnamed-chunk-6-1.gif │ ├── README-unnamed-chunk-6-1.png │ ├── README-unnamed-chunk-7-1.gif │ └── logo.png │ ├── ggpage_build-1.png │ ├── ggpage_build-2.png │ ├── ggpage_build-3.png │ ├── ggpage_build-4.png │ ├── ggpage_build-5.png │ ├── ggpage_build-6.png │ ├── ggpage_build-7.png │ ├── ggpage_build.html │ ├── ggpage_plot-1.png │ ├── ggpage_plot-2.png │ ├── ggpage_plot-3.png │ ├── ggpage_plot-4.png │ ├── ggpage_plot-5.png │ ├── ggpage_plot-6.png │ ├── ggpage_plot-7.png │ ├── ggpage_plot.html │ ├── ggpage_quick-1.png │ ├── ggpage_quick-2.png │ ├── ggpage_quick-3.png │ ├── ggpage_quick.html │ ├── index.html │ ├── line_align.html │ ├── nest_paragraphs.html │ ├── page_liner.html │ ├── paper_shape.html │ ├── para_index.html │ ├── pipe.html │ ├── tinderbox.html │ ├── tinderbox_paragraph.html │ └── word_to_line.html ├── ggpage.Rproj ├── man ├── break_help.Rd ├── figures │ ├── README-unnamed-chunk-4-1.png │ ├── README-unnamed-chunk-6-1.png │ └── logo.png ├── ggpage_build.Rd ├── ggpage_plot.Rd ├── ggpage_quick.Rd ├── line_align.Rd ├── nest_paragraphs.Rd ├── page_liner.Rd ├── paper_shape.Rd ├── para_index.Rd ├── pipe.Rd ├── tinderbox.Rd ├── tinderbox_paragraph.Rd └── word_to_line.Rd ├── pkgdown └── favicon │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ ├── apple-touch-icon-180x180.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── favicon.ico ├── tests ├── testthat.R └── testthat │ ├── test-break_help.R │ ├── test-paper_shape.R │ └── test-para_index.R └── vignettes ├── .gitignore └── different-features.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^pkgdown$ 2 | ^docs$ 3 | ^_pkgdown\.yml$ 4 | ^.*\.Rproj$ 5 | ^\.Rproj\.user$ 6 | README.Rmd 7 | ^\.travis\.yml$ 8 | ^data-raw$ 9 | ^codecov\.yml$ 10 | ^cran-comments\.md$ 11 | ^appveyor\.yml$ 12 | ^CRAN-RELEASE$ 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | inst/doc 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | sudo: false 5 | cache: packages 6 | 7 | after_success: 8 | - Rscript -e 'covr::codecov()' 9 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Package 2 | Package: ggpage 3 | Title: Creates Page Layout Visualizations 4 | Version: 0.2.3.9000 5 | Authors@R: 6 | person(given = "Emil", 7 | family = "Hvitfeldt", 8 | role = c("aut", "cre"), 9 | email = "emilhhvitfeldt@gmail.com") 10 | Description: Facilitates the creation of page layout 11 | visualizations in which words are represented as rectangles with sizes 12 | relating to the length of the words. Which then is divided in lines 13 | and pages for easy overview of up to quite large texts. 14 | License: MIT + file LICENSE 15 | URL: https://github.com/EmilHvitfeldt/ggpage 16 | BugReports: https://github.com/EmilHvitfeldt/ggpage/issues 17 | Depends: 18 | R (>= 3.0.0) 19 | Imports: 20 | dplyr, 21 | ggplot2 (>= 2.0.0), 22 | magrittr, 23 | purrr, 24 | rlang, 25 | stringr, 26 | tidytext (>= 0.1.0) 27 | Suggests: 28 | covr, 29 | knitr, 30 | rmarkdown, 31 | testthat 32 | VignetteBuilder: 33 | knitr 34 | Encoding: UTF-8 35 | LazyData: true 36 | RoxygenNote: 6.1.1 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2017 2 | COPYRIGHT HOLDER: Emil Hvitfeldt 3 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export("%>%") 4 | export(break_help) 5 | export(ggpage_build) 6 | export(ggpage_plot) 7 | export(ggpage_quick) 8 | export(line_align) 9 | export(nest_paragraphs) 10 | export(page_liner) 11 | export(paper_shape) 12 | export(para_index) 13 | export(word_to_line) 14 | importFrom(magrittr,"%>%") 15 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # ggpage (development version) 2 | 3 | # ggpage 0.2.3 4 | 5 | # ggpage 0.2.2 6 | 7 | * Added a `NEWS.md` file to track changes to the package. 8 | -------------------------------------------------------------------------------- /R/data.R: -------------------------------------------------------------------------------- 1 | #' The tinder-box by H.C. Andersen 2 | #' 3 | #' A tidy data.frame containing the entire story of The tinder-box by H.C. 4 | #' Andersen with two columns: \code{text} which contains the text of the 5 | #' fairy tale divided into elements of up to about 80 characters each and 6 | #' \code{book} giving the name of the fairy tale in question. 7 | #' 8 | #' @format A data frame with 211 rows and 2 variables: 9 | #' \describe{ 10 | #' \item{text}{character string up to 80 characters each} 11 | #' \item{book}{name of the fairy tale} 12 | #' ... 13 | #' } 14 | "tinderbox" 15 | 16 | #' The tinder-box by H.C. Andersen 17 | #' 18 | #' A tidy data.frame containing the entire story of The tinder-box by H.C. 19 | #' Andersen with two columns: \code{text} which contains the text of the 20 | #' fairy tale divided into paragraphs. 21 | #' 22 | #' @format A data frame with 11 rows and 1 variables: 23 | #' \describe{ 24 | #' \item{text}{character string up to 80 characters each} 25 | #' ... 26 | #' } 27 | "tinderbox_paragraph" 28 | -------------------------------------------------------------------------------- /R/ggpage_build.R: -------------------------------------------------------------------------------- 1 | #' Creates a data frame for further analysis and plotting 2 | #' 3 | #' This function can be used in combination with \code{ggpage_plot} to get the 4 | #' same result as \code{ggpage_quick}. However by splitting the data.frame 5 | #' construction and plotting we are able to do intermediate analysis which 6 | #' can be included in the visualization. 7 | #' 8 | #' The text MUST be presented in a column named text. 9 | #' 10 | #' @param book Character or data.frame. Can either have each element be a 11 | #' separate line or having each element being separate words. 12 | #' @param lpp Numeric. Lines Per Page. Number of lines allocated for each page. 13 | #' @param character_height Numeric. Relative size of the height of each letter 14 | #' compared to its width. 15 | #' @param vertical_space Numeric. Distance between each lines vertically. 16 | #' @param x_space_pages Numeric. Distance between pages along the x-axis. 17 | #' @param y_space_pages Numeric. Distance between pages along the y-axis. 18 | #' @param nrow Numeric. Number of rows of pages, if omitted defaults to square 19 | #' layout. 20 | #' @param ncol Numeric. Number of columns of pages, if omitted defaults to 21 | #' square layout. 22 | #' @param bycol Logical. If TRUE (the default) the matrix is filled by 23 | #' columns, otherwise the matrix is filled by rows. 24 | #' @param wtl logical. If TRUE will convert single word vector into a vector 25 | #' with full lines. (defaults to FALSE). 26 | #' @param para.fun Function that generates random numbers to determine number 27 | #' of word in each paragraph. 28 | #' @param page.col column to split the pages by. 29 | #' @param align Type of line alignment. Must be one of "left", "right" or "both". 30 | #' @param line.max Maximal number of characters per line. Defaults to 80. 31 | #' @param ... Extra arguments. 32 | #' @return `data.frame` containing the following columns: 33 | #' \itemize{ 34 | #' \item `word`: Character. The words of the text. 35 | #' \item `page`: Integer. Page number. 36 | #' \item `line`: Integer. Line number within the page. 37 | #' \item `xmin`: Numeric. Border of rectangle, used by \code{ggpage_plot} do not 38 | #' alter. 39 | #' \item `xmax`: Numeric. Border of rectangle, used by \code{ggpage_plot} do not 40 | #' alter. 41 | #' \item `ymin`: Numeric. Border of rectangle, used by \code{ggpage_plot} do not 42 | #' alter. 43 | #' \item `ymax`: Numeric. Border of rectangle, used by \code{ggpage_plot} do not 44 | #' alter. 45 | #' } 46 | #' @examples 47 | #' \donttest{ 48 | #' library(dplyr) 49 | #' library(stringr) 50 | #' library(ggplot2) 51 | #' library(tidytext) 52 | #' library(ggpage) 53 | #' # build and plot 54 | #' ## data.frame with full lines 55 | #' ggpage_build(tinderbox) %>% 56 | #' ggpage_plot() 57 | #' ## vector with full lines 58 | #' ggpage_build(book = tinderbox %>% 59 | #' pull(text)) %>% 60 | #' ggpage_plot() 61 | #' ## data.frame with single words 62 | #' ggpage_build(tinderbox) %>% 63 | #' unnest_tokens(text, word) %>% 64 | #' ggpage_plot() 65 | #' ## vector with single words 66 | #' ggpage_build(tinderbox %>% 67 | #' unnest_tokens(text, text) %>% 68 | #' pull(text)) %>% 69 | #' ggpage_plot() 70 | #' 71 | #' # nrow and ncol 72 | #' ggpage_build(tinderbox, nrow = 2) %>% 73 | #' ggpage_plot() 74 | #' ggpage_build(tinderbox, ncol = 2) %>% 75 | #' ggpage_plot() 76 | #' 77 | #' # Include analysis within 78 | #' ggpage_build(tinderbox) %>% 79 | #' mutate(word_length = str_length(word)) %>% 80 | #' ggpage_plot(aes(fill = word_length)) 81 | #' } 82 | #' @export 83 | ggpage_build <- function(book, lpp = 25, character_height = 3, 84 | vertical_space = 1, x_space_pages = 10, 85 | y_space_pages = 10, nrow = NULL, ncol = NULL, 86 | bycol = TRUE, wtl = NULL, 87 | para.fun = NULL, page.col = NULL, align = "left", 88 | line.max = 80, 89 | ...) { 90 | 91 | if (!any(class(book) %in% c("character", "data.frame"))) { 92 | stop("Please supply character string or data.frame.") 93 | } 94 | 95 | book0 <- book 96 | 97 | # Makes strings to data.frames 98 | if (inherits(book, "character")) { 99 | book <- data.frame(text = book, stringsAsFactors = FALSE) 100 | } 101 | 102 | # Makes single words to lines 103 | single_word_check <- book %>% 104 | dplyr::slice(1:25) %>% 105 | dplyr::pull(.data$text) %>% 106 | trimws("both") %>% 107 | stringr::str_detect(" ") %>% 108 | mean() < 0.9 109 | 110 | if (is.null(wtl)) wtl <- single_word_check 111 | 112 | if (wtl) { 113 | 114 | if (is.null(para.fun)) { 115 | book <- data.frame(text = word_to_line(book), stringsAsFactors = FALSE) 116 | } else { 117 | if (!is.function(para.fun)) stop("para.fun must be a function") 118 | 119 | book <- book %>% 120 | dplyr::mutate(paragraph_id = para_index(NROW(book), para.fun, ...) %>% 121 | break_help()) 122 | 123 | book <- purrr::map_df(dplyr::pull(book, .data$paragraph_id) %>% unique(), 124 | ~ book %>% 125 | dplyr::filter(paragraph_id == .x) %>% 126 | word_to_line() %>% 127 | data.frame(text = ., stringsAsFactors = FALSE)) 128 | 129 | } 130 | } 131 | 132 | # Data table with full lines needed here 133 | if (is.null(page.col)) { 134 | data <- book %>% 135 | dplyr::mutate(index_line = 1:NROW(book), 136 | page = rep(1:ceiling(NROW(book) / lpp), 137 | length.out = NROW(book), 138 | each = lpp)) 139 | } else { 140 | page.col <- rlang::quo_name(rlang::enquo(page.col)) 141 | 142 | data <- book %>% 143 | dplyr::mutate(index_line = 1:NROW(book), 144 | page = book0[[page.col]]) 145 | } 146 | 147 | data <- data %>% 148 | page_liner() %>% 149 | tidytext::unnest_tokens(output = "word", input = "text") %>% 150 | dplyr::mutate(word_length = stringr::str_length(.data$word)) %>% 151 | dplyr::group_by(.data$index_line) %>% 152 | dplyr::mutate( 153 | first_word = dplyr::lag(.data$line, default = 0) != .data$line, 154 | x_space_right = cumsum(.data$word_length + 1) - 1, 155 | x_space_left = cumsum(dplyr::lag(.data$word_length + 1, 156 | default = 0))) %>% 157 | dplyr::ungroup() 158 | 159 | # Longest line 160 | max_line_length <- book %>% 161 | dplyr::pull(.data$text) %>% 162 | stringr::str_length() %>% 163 | max() 164 | 165 | # Add page spacing 166 | num_pages <- data %>% 167 | dplyr::pull(.data$page) %>% 168 | dplyr::n_distinct() 169 | 170 | if (!is.null(nrow) || !is.null(ncol)) { 171 | if (!is.null(nrow)) { 172 | n_row_y <- nrow 173 | n_row_x <- ceiling(num_pages / n_row_y) 174 | } 175 | if (!is.null(ncol)) { 176 | n_row_x <- ncol 177 | n_row_y <- ceiling(num_pages / n_row_x) 178 | } 179 | } else { 180 | n_row_x <- n_row_y <- ceiling(sqrt(num_pages)) 181 | } 182 | 183 | if (bycol) { 184 | page_spacing <- data.frame( 185 | page = 1:num_pages, 186 | x_page = rep(1:n_row_x, length.out = num_pages, each = n_row_y), 187 | y_page = rep(1:n_row_y, length.out = num_pages) 188 | ) 189 | } else { 190 | page_spacing <- data.frame( 191 | page = 1:num_pages, 192 | x_page = rep(1:n_row_x, length.out = num_pages), 193 | y_page = rep(1:n_row_y, length.out = num_pages, each = n_row_x) 194 | ) 195 | } 196 | 197 | data <- data %>% 198 | dplyr::left_join(page_spacing, by = "page") %>% 199 | dplyr::mutate( 200 | xmin = .data$x_space_right + .data$x_page * (max_line_length + x_space_pages), 201 | xmax = .data$x_space_left + .data$x_page * (max_line_length + x_space_pages), 202 | ymin = - .data$line * (character_height + vertical_space) - .data$y_page * 203 | (lpp * (character_height + vertical_space) + y_space_pages), 204 | ymax = - .data$line * (character_height + vertical_space) - 205 | character_height - .data$y_page * 206 | (lpp * (character_height + vertical_space) + y_space_pages)) %>% 207 | dplyr::select(-.data$index_line, -.data$word_length, -.data$first_word, 208 | -.data$x_space_right, -.data$x_space_left, -.data$x_page, 209 | -.data$y_page) %>% 210 | dplyr::select(.data$word, dplyr::everything()) 211 | 212 | # Text alignment 213 | data %>% 214 | dplyr::mutate(index_line = stringr::str_c(.data$page, .data$line, sep = "-")) %>% 215 | dplyr::group_by(.data$index_line) %>% 216 | dplyr::do(line_align(., line.max, align)) %>% 217 | dplyr::ungroup() 218 | } 219 | -------------------------------------------------------------------------------- /R/ggpage_plot.R: -------------------------------------------------------------------------------- 1 | #' Creates a visualization from the ggpage_build output 2 | #' 3 | #' @param data data.frame. Expects output from \code{ggpage_build} with 4 | #' optional intermediate analysis. 5 | #' @param mapping Default list of aesthetic mappings to use for plot to be 6 | #' handed to internal \code{ggplot} call. 7 | #' @param paper.show Shows the paper underneath the text. 8 | #' @param paper.color Color of the pages. Needs to be of length 1 or the same 9 | #' as the number of pages. 10 | #' @param paper.alpha Alpha of the pages. Needs to be of length 1 or the same 11 | #' as the number of pages. 12 | #' @param paper.limits Numerical. Extends the edges of the paper in all 13 | #' directions. 14 | #' @param page.number Position of the page number. Defaults to none. 15 | #' @param page.number.x Distance the page number is pushed away from the text 16 | #' along the x-axis. 17 | #' @param page.number.y Distance the page number is pushed away from the text 18 | #' along the y-axis. 19 | #' @return A ggplot object with the given visualization. 20 | #' @examples 21 | #' \donttest{ 22 | #' library(dplyr) 23 | #' library(stringr) 24 | #' library(ggplot2) 25 | #' library(tidytext) 26 | #' library(ggpage) 27 | #' # build and plot 28 | #' ## data.frame with full lines 29 | #' ggpage_build(tinderbox) %>% 30 | #' ggpage_plot() 31 | #' ## vector with full lines 32 | #' ggpage_build(book = tinderbox %>% 33 | #' pull(text)) %>% 34 | #' ggpage_plot() 35 | #' ## data.frame with single words 36 | #' ggpage_build(tinderbox) %>% 37 | #' unnest_tokens(text, word) %>% 38 | #' ggpage_plot() 39 | #' ## vector with single words 40 | #' ggpage_build(tinderbox %>% 41 | #' unnest_tokens(text, text) %>% 42 | #' pull(text)) %>% 43 | #' ggpage_plot() 44 | #' 45 | #' # nrow and ncol 46 | #' ggpage_build(tinderbox, nrow = 2) %>% 47 | #' ggpage_plot() 48 | #' ggpage_build(tinderbox, ncol = 2) %>% 49 | #' ggpage_plot() 50 | #' 51 | #' # Include analysis within 52 | #' ggpage_build(tinderbox) %>% 53 | #' mutate(word_length = str_length(word)) %>% 54 | #' ggpage_plot(aes(fill = word_length)) 55 | #' } 56 | #' @export 57 | ggpage_plot <- function(data, mapping = ggplot2::aes(), 58 | paper.show = FALSE, paper.color = "grey90", 59 | paper.alpha = 1, paper.limits = 3, 60 | page.number = character(1), page.number.x = 3, 61 | page.number.y = 3) { 62 | p <- data %>% 63 | ggplot2::ggplot(mapping = mapping) + 64 | ggplot2::geom_rect(ggplot2::aes(xmin = data$xmin, xmax = data$xmax, 65 | ymin = data$ymin, ymax = data$ymax)) + 66 | ggplot2::coord_fixed(ratio = 1) + 67 | ggplot2::theme_void() 68 | 69 | if(paper.show) { 70 | paper_data <- data %>% paper_shape() 71 | 72 | p <- p + 73 | ggplot2::geom_rect(data = paper_data, 74 | ggplot2::aes(xmin = paper_data$xmin + paper.limits, 75 | xmax = paper_data$xmax - paper.limits, 76 | ymin = paper_data$ymin + paper.limits, 77 | ymax = paper_data$ymax - paper.limits), 78 | fill = paper.color, alpha = paper.alpha) 79 | p$layers = rev(p$layers) 80 | } 81 | 82 | directions <- c("top", "top-right", "right", "bottom-right", "bottom", 83 | "bottom-left", "left", "top-left") 84 | if(page.number %in% directions) { 85 | paper_number_data <- data %>% 86 | paper_shape() 87 | 88 | page.number <- match.arg(page.number, directions) 89 | 90 | if(page.number %in% c("top-right", "right", "bottom-right")) { 91 | page_x <- paper_number_data$xmin + page.number.x 92 | } else if(page.number %in% c("top-left", "left", "bottom-left")) { 93 | page_x <- paper_number_data$xmax - page.number.x 94 | } else { 95 | page_x <- (paper_number_data$xmax - paper_number_data$xmin) / 2 + 96 | paper_number_data$xmin 97 | } 98 | 99 | if(page.number %in% c("top-left", "top", "top-right")) { 100 | page_y <- paper_number_data$ymin + page.number.y 101 | } else if(page.number %in% c("bottom-left", "bottom", "bottom-right")) { 102 | page_y <- paper_number_data$ymax - page.number.y 103 | } else { 104 | page_y <- (paper_number_data$ymax - paper_number_data$ymin) / 2 + 105 | paper_number_data$ymin 106 | } 107 | 108 | p <- p + 109 | ggplot2::geom_text(data = paper_number_data, inherit.aes = FALSE, 110 | ggplot2::aes(x = page_x, y = page_y, 111 | label = paper_number_data$page)) 112 | } 113 | 114 | p 115 | } 116 | -------------------------------------------------------------------------------- /R/ggpage_quick.R: -------------------------------------------------------------------------------- 1 | #' Creates a quick visualization of the page layout 2 | #' 3 | #' @param book Character or data.frame. Can either have each element be a 4 | #' separate line or having each element being separate words. 5 | #' @param lpp Numeric. Lines Per Page. Number of lines allocated for each page. 6 | #' @param character_height Numeric. Relative size of the height of each letter 7 | #' compared to its width. 8 | #' @param vertical_space Numeric. Distance between each lines vertically. 9 | #' @param x_space_pages Numeric. Distance between pages along the x-axis. 10 | #' @param y_space_pages Numeric. Distance between pages along the y-axis. 11 | #' @param nrow Numeric. Number of rows of pages, if omitted defaults to square 12 | #' layout. 13 | #' @param ncol Numeric. Number of columns of pages, if omitted defaults to 14 | #' square layout. 15 | #' @param bycol Logical. If TRUE (the default) the matrix is filled by 16 | #' columns, otherwise the matrix is filled by rows. 17 | #' @return A ggplot object with the given visualization. 18 | #' @examples 19 | #' \donttest{ 20 | #' library(dplyr) 21 | #' library(stringr) 22 | #' library(ggplot2) 23 | #' library(tidytext) 24 | #' library(ggpage) 25 | #' # quick 26 | #' ## data.frame with full lines 27 | #' ggpage_quick(tinderbox) 28 | #' ## vector with full lines 29 | #' ggpage_quick(tinderbox %>% 30 | #' pull(text)) 31 | #' ## data.frame with single words 32 | #' ggpage_quick(tinderbox %>% 33 | #' unnest_tokens(text, text)) 34 | #' ## vector with single words 35 | #' ggpage_quick(tinderbox %>% 36 | #' unnest_tokens(text, text) %>% 37 | #' pull(text)) 38 | #' 39 | #' # nrow and ncol 40 | #' ggpage_quick(tinderbox, nrow = 2) 41 | #' ggpage_quick(tinderbox, ncol = 2) 42 | #' } 43 | #' @export 44 | ggpage_quick <- function(book, lpp = 25, character_height = 3, 45 | vertical_space = 1, x_space_pages = 10, 46 | y_space_pages = 10, nrow = NULL, ncol = NULL, 47 | bycol = TRUE) { 48 | 49 | if(!any(class(book) %in% c("character", "data.frame"))) { 50 | stop("Please supply character string or data.frame.") 51 | } 52 | 53 | # Makes strings to data.frames 54 | if (inherits(book, "character")) { 55 | book <- data.frame(text = book) 56 | } 57 | 58 | # Makes single words to lines 59 | if (book %>% 60 | dplyr::slice(1:25) %>% 61 | dplyr::pull(.data$text) %>% 62 | stringr::str_detect(" ") %>% 63 | mean() < 0.9) { 64 | book <- data.frame(text = word_to_line(book)) 65 | } 66 | 67 | # Data table with full lines needed here 68 | n <- NROW(book) 69 | 70 | data <- book %>% 71 | dplyr::mutate(index_line = dplyr::row_number(), 72 | page = rep(1:ceiling(n / lpp), 73 | length.out = n, 74 | each = lpp)) %>% 75 | dplyr::group_by(.data$page) %>% 76 | dplyr::mutate(line = dplyr::row_number()) %>% 77 | dplyr::ungroup() %>% 78 | tidytext::unnest_tokens(output = "word", input = "text") %>% 79 | dplyr::mutate(word_length = stringr::str_length(.data$word)) %>% 80 | dplyr::group_by(.data$index_line) %>% 81 | dplyr::mutate(first_word = dplyr::lag(.data$line, default = 0) != .data$line, 82 | x_space_right = cumsum(.data$word_length + 1) - 1, 83 | x_space_left = cumsum(dplyr::lag(.data$word_length + 1, 84 | default = 0))) %>% 85 | dplyr::ungroup() 86 | 87 | # Longest line 88 | max_line_length <- book %>% 89 | dplyr::pull(.data$text) %>% 90 | stringr::str_length() %>% 91 | max() 92 | 93 | # Add page spacing 94 | num_pages <- data %>% 95 | dplyr::pull(.data$page) %>% 96 | dplyr::n_distinct() 97 | 98 | if (!is.null(nrow) || !is.null(ncol)) { 99 | if (!is.null(ncol)) { 100 | n_row_y <- ncol 101 | n_row_x <- ceiling(num_pages / n_row_y) 102 | } 103 | if (!is.null(nrow)) { 104 | n_row_x <- nrow 105 | n_row_y <- ceiling(num_pages / n_row_x) 106 | } 107 | } else { 108 | n_row_x <- n_row_y <- ceiling(sqrt(num_pages)) 109 | } 110 | 111 | if (bycol) { 112 | page_spacing <- data.frame( 113 | page = 1:num_pages, 114 | x_page = rep(1:n_row_x, length.out = num_pages, each = n_row_y), 115 | y_page = rep(1:n_row_y, length.out = num_pages) 116 | ) 117 | } else { 118 | page_spacing <- data.frame( 119 | page = 1:num_pages, 120 | x_page = rep(1:n_row_x, length.out = num_pages), 121 | y_page = rep(1:n_row_y, length.out = num_pages, each = n_row_x) 122 | ) 123 | } 124 | 125 | data_1 <- data %>% 126 | dplyr::left_join(page_spacing, by = "page") 127 | 128 | data_1 %>% 129 | ggplot2::ggplot() + 130 | ggplot2::geom_rect(ggplot2::aes(xmin = data_1$x_space_right + data_1$x_page * 131 | (max_line_length + x_space_pages), 132 | xmax = data_1$x_space_left + data_1$x_page * 133 | (max_line_length + x_space_pages), 134 | ymin = - data_1$line * (character_height + vertical_space) - 135 | data_1$y_page * (lpp * (character_height + vertical_space) + 136 | y_space_pages), 137 | ymax = - data_1$line * (character_height + vertical_space) - 138 | character_height - data_1$y_page * 139 | (lpp * (character_height + vertical_space) + 140 | y_space_pages))) + 141 | ggplot2::coord_fixed(ratio = 1) + 142 | ggplot2::theme_void() 143 | } 144 | -------------------------------------------------------------------------------- /R/global.R: -------------------------------------------------------------------------------- 1 | if(getRversion() >= "2.15.1") utils::globalVariables(c(".", ".data")) 2 | -------------------------------------------------------------------------------- /R/nest_paragraphs.R: -------------------------------------------------------------------------------- 1 | #' converts paragraph tokens into line tokens 2 | #' 3 | #' extents the str_wrap() function from the stringr package to work with longer 4 | #' strings. 5 | #' 6 | #' @param data data.frame. With one paragraph per row. 7 | #' @param input column that gets split as string or symbol. 8 | #' @param ... Extra arguments passed to str_wrap. 9 | #' @return data.frame. 10 | #' @export 11 | nest_paragraphs <- function(data, input, ...) { 12 | quo_input <- rlang::quo_name(rlang::enquo(input)) 13 | 14 | sections <- data[[quo_input]] %>% 15 | stringr::str_wrap(...) %>% 16 | stringr::str_split("\n") 17 | 18 | purrr::map_df(seq_len(nrow(data)), 19 | ~ data.frame(text = sections[[.x]], stringsAsFactors = FALSE) %>% 20 | bind_cols( 21 | bind_rows( 22 | replicate( 23 | length(sections[[.x]]), 24 | dplyr::select(data, -which(names(data) == quo_input))[.x, ], 25 | simplify = FALSE) 26 | ) 27 | ) 28 | ) 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /R/utils-pipe.R: -------------------------------------------------------------------------------- 1 | #' Pipe operator 2 | #' 3 | #' See \code{magrittr::\link[magrittr]{\%>\%}} for details. 4 | #' 5 | #' @name %>% 6 | #' @rdname pipe 7 | #' @keywords internal 8 | #' @export 9 | #' @importFrom magrittr %>% 10 | #' @usage lhs \%>\% rhs 11 | NULL 12 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | #' Internal function for converting words to lines 2 | #' 3 | #' extents the str_wrap() function from the stringr package to work with longer 4 | #' strings. 5 | #' 6 | #' @param words data.frame. Where each row is a separate word words with the 7 | #' column name text. 8 | #' @param wot_number Numeric. how many words to split whole string by. 9 | #' @return Character. have each element be a separate line. 10 | #' @export 11 | word_to_line <- function(words, wot_number = 1000) { 12 | 13 | words %>% 14 | dplyr::mutate(split = floor((seq_len(NROW(words)) - 1L) / wot_number)) %>% 15 | split(.$split) %>% 16 | purrr::map(~ .x %>% dplyr::pull(.data$text) %>% 17 | stringr::str_c(collapse = " ") %>% 18 | stringr::str_wrap() %>% 19 | stringr::str_split("\n *")) %>% 20 | unlist() 21 | 22 | } 23 | 24 | #' paragraph split 25 | #' 26 | #' Converts a word vector into a line vector with variable paragraph lengths. 27 | #' 28 | #' FUN most be a function that takes in a number n and returns a vector of 29 | #' natural numbers. 30 | #' 31 | #' @param n Numeric. Numbers of words. 32 | #' @param FUN Numeric. how many words to split whole string by. 33 | #' @param ... Extra arguments. 34 | #' @return Numeric. paragraph indicator. 35 | #' @export 36 | para_index <- function(n, FUN, ...) { 37 | 38 | numbers <- FUN(n, ...) 39 | 40 | if(any(numbers < 0)) stop("FUN must return non-negative numbers.") 41 | 42 | index <- sum(cumsum(numbers) < n) + 1 43 | out <- numbers[seq_len(index)] 44 | 45 | out[index] <- out[index] - (sum(out) - n) 46 | out 47 | } 48 | 49 | #' Repeating of indexes 50 | #' 51 | #' @param x Numerical, vector. 52 | #' @return Numerical. 53 | #' @examples 54 | #' break_help(c(1, 2, 3)) 55 | #' break_help(c(6, 8, 23, 50)) 56 | #' @export 57 | break_help <- function(x) { 58 | unlist( 59 | purrr::map2(x, 1:length(x), ~ rep(.y, .x)) 60 | ) 61 | } 62 | 63 | #' Identify the edges of the paper of each page 64 | #' 65 | #' @param data data.frame created by ggpage_build. 66 | #' @return data.frame, 67 | #' @examples 68 | #' paper_shape(ggpage_build(tinderbox)) 69 | #' @export 70 | paper_shape <- function(data) { 71 | dplyr::group_by(data, .data$page) %>% 72 | dplyr::summarise(xmin = max(.data$xmin), 73 | xmax = min(.data$xmax), 74 | ymin = max(.data$ymin), 75 | ymax = min(.data$ymax)) 76 | } 77 | 78 | #' Add line number within pages 79 | #' 80 | #' @param data data.frame 81 | #' @return data.frame 82 | #' @export 83 | page_liner <- function(data) { 84 | line <- data %>% 85 | dplyr::group_by(.data$page) %>% 86 | dplyr::tally() %>% 87 | dplyr::pull(.data$n) %>% 88 | purrr::map(~ seq_len(.x)) %>% 89 | unlist() 90 | 91 | data %>% 92 | dplyr::mutate(line) 93 | } 94 | 95 | #' Adjust lines 96 | #' 97 | #' @param line data.frame 98 | #' @param max_length numerical. number of letters allowed on a line. 99 | #' @param type Type of line alignment. Must be one of "left", "right" or "both". 100 | #' @return data.frame 101 | #' @export 102 | line_align <- function(line, max_length, type) { 103 | 104 | line_length <- abs(max(line$xmin) - min(line$xmax)) 105 | n_words <- NROW(line) 106 | 107 | adjust <- 0 108 | 109 | if(n_words > 1) { 110 | if(type == "both") { 111 | adjust <- c(0, (max_length - line_length) / (n_words - 1) * seq_len(n_words - 1)) 112 | } 113 | } 114 | if(type == "right") { 115 | adjust <- max_length - line_length 116 | } 117 | if(type == "left") { 118 | adjust <- 0 119 | } 120 | line$xmax <- line$xmax + adjust 121 | line$xmin <- line$xmin + adjust 122 | 123 | line 124 | } 125 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | ```{r, echo = FALSE} 5 | knitr::opts_chunk$set( 6 | collapse = TRUE, 7 | comment = "#>", 8 | fig.path = "man/figures/README-" 9 | ) 10 | ``` 11 | 12 | # ggpage 13 | 14 | [![Travis build status](https://travis-ci.org/EmilHvitfeldt/ggpage.svg?branch=master)](https://travis-ci.org/EmilHvitfeldt/ggpage) 15 | [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/EmilHvitfeldt/ggpage?branch=master&svg=true)](https://ci.appveyor.com/project/EmilHvitfeldt/ggpage) 16 | [![Coverage status](https://codecov.io/gh/EmilHvitfeldt/ggpage/branch/master/graph/badge.svg)](https://codecov.io/github/EmilHvitfeldt/ggpage?branch=master) 17 | [![CRAN status](https://www.r-pkg.org/badges/version/ggpage)](https://cran.r-project.org/package=ggpage) 18 | 19 | **ggpage** is a package to create pagestyled visualizations of text based data. It uses ggplot2 and final returns are ggplot2 objects. 20 | 21 | ## Version 0.2.0 22 | 23 | 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. 24 | 25 | ## Installation 26 | 27 | You can install the released version of **ggpage** from [CRAN](https://cran.r-project.org/) with: 28 | 29 | ```{r eval = FALSE} 30 | install.packages("ggpage") 31 | ``` 32 | 33 | or you can install the developmental version of **ggpage** from github with: 34 | 35 | ```{r gh-installation, eval = FALSE} 36 | # install.packages("devtools") 37 | devtools::install_github("EmilHvitfeldt/ggpage") 38 | ``` 39 | 40 | ## Example 41 | 42 | The package includes The Tinder-box by H.C. Andersen for examples. 43 | 44 | ```{r message=FALSE} 45 | library(tidyverse) 46 | library(ggpage) 47 | 48 | head(tinderbox, 10) 49 | ``` 50 | 51 | The basic workflow with **ggpage** is using either 52 | 53 | - `ggpage_quick` for a quick one function call plot or, 54 | - combining `ggpage_build` and `ggpage_plot` to do analysis (NLP for example) before the final plot is produced. 55 | 56 | 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". 57 | 58 | ```{r} 59 | ggpage_quick(tinderbox) 60 | 61 | # Also pipeable 62 | # tinderbox %>% ggpage_quick() 63 | ``` 64 | 65 | The same result would be achieved by using 66 | 67 | ```{r eval=FALSE} 68 | tinderbox %>% 69 | ggpage_build() %>% 70 | ggpage_plot() 71 | ``` 72 | 73 | But this approach allows us to introduce more code between `ggpage_build` and `ggpage_plot` giving us multiple more ways to enhance the plots 74 | 75 | ```{r} 76 | tinderbox %>% 77 | ggpage_build() %>% 78 | mutate(long_word = stringr::str_length(word) > 8) %>% 79 | ggpage_plot(aes(fill = long_word)) + 80 | labs(title = "Longer words throughout The Tinder-box") + 81 | scale_fill_manual(values = c("grey70", "blue"), 82 | labels = c("8 or less", "9 or more"), 83 | name = "Word length") 84 | ``` 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # ggpage 3 | 4 | [![Travis build 5 | status](https://travis-ci.org/EmilHvitfeldt/ggpage.svg?branch=master)](https://travis-ci.org/EmilHvitfeldt/ggpage) 6 | [![AppVeyor build 7 | status](https://ci.appveyor.com/api/projects/status/github/EmilHvitfeldt/ggpage?branch=master&svg=true)](https://ci.appveyor.com/project/EmilHvitfeldt/ggpage) 8 | [![Coverage 9 | status](https://codecov.io/gh/EmilHvitfeldt/ggpage/branch/master/graph/badge.svg)](https://codecov.io/github/EmilHvitfeldt/ggpage?branch=master) 10 | [![CRAN 11 | status](https://www.r-pkg.org/badges/version/ggpage)](https://cran.r-project.org/package=ggpage) 12 | 13 | **ggpage** is a package to create pagestyled visualizations of text 14 | based data. It uses ggplot2 and final returns are ggplot2 objects. 15 | 16 | ## Version 0.2.0 17 | 18 | In this new version I have worked to include a lot of use cases that 19 | wasn’t available in the first version. These new elements are previewed 20 | in the vignette. 21 | 22 | ## Installation 23 | 24 | You can install the released version of **ggpage** from 25 | [CRAN](https://cran.r-project.org/) with: 26 | 27 | ``` r 28 | install.packages("ggpage") 29 | ``` 30 | 31 | or you can install the developmental version of **ggpage** from github 32 | with: 33 | 34 | ``` r 35 | # install.packages("devtools") 36 | devtools::install_github("EmilHvitfeldt/ggpage") 37 | ``` 38 | 39 | ## Example 40 | 41 | The package includes The Tinder-box by H.C. Andersen for examples. 42 | 43 | ``` r 44 | library(tidyverse) 45 | #> Warning: replacing previous import 'dplyr::vars' by 'rlang::vars' when 46 | #> loading 'dbplyr' 47 | library(ggpage) 48 | 49 | head(tinderbox, 10) 50 | #> # A tibble: 10 x 2 51 | #> text book 52 | #> 53 | #> 1 "A soldier came marching along the high road: \"Left, righ… The tinder-… 54 | #> 2 had his knapsack on his back, and a sword at his side; he … The tinder-… 55 | #> 3 and was now returning home. As he walked on, he met a very… The tinder-… 56 | #> 4 witch in the road. Her under-lip hung quite down on her br… The tinder-… 57 | #> 5 "and said, \"Good evening, soldier; you have a very fine s… The tinder-… 58 | #> 6 knapsack, and you are a real soldier; so you shall have as… The tinder-… 59 | #> 7 "you like.\"" The tinder-… 60 | #> 8 "\"Thank you, old witch,\" said the soldier." The tinder-… 61 | #> 9 "\"Do you see that large tree,\" said the witch, pointing … The tinder-… 62 | #> 10 "beside them. \"Well, it is quite hollow inside, and you m… The tinder-… 63 | ``` 64 | 65 | The basic workflow with **ggpage** is using either 66 | 67 | - `ggpage_quick` for a quick one function call plot or, 68 | - combining `ggpage_build` and `ggpage_plot` to do analysis (NLP for 69 | example) before the final plot is produced. 70 | 71 | For a simple demonstration we apply `ggpage_quick` to our `tinderbox` 72 | object. It is important that the data.frame that is used have the text 73 | in a column named “text”. 74 | 75 | ``` r 76 | ggpage_quick(tinderbox) 77 | #> Warning: replacing previous import 'dplyr::vars' by 'rlang::vars' when 78 | #> loading 'tidytext' 79 | ``` 80 | 81 | ![](man/figures/README-unnamed-chunk-4-1.png) 82 | 83 | ``` r 84 | 85 | # Also pipeable 86 | # tinderbox %>% ggpage_quick() 87 | ``` 88 | 89 | The same result would be achieved by using 90 | 91 | ``` r 92 | tinderbox %>% 93 | ggpage_build() %>% 94 | ggpage_plot() 95 | ``` 96 | 97 | But this approach allows us to introduce more code between 98 | `ggpage_build` and `ggpage_plot` giving us multiple more ways to enhance 99 | the plots 100 | 101 | ``` r 102 | tinderbox %>% 103 | ggpage_build() %>% 104 | mutate(long_word = stringr::str_length(word) > 8) %>% 105 | ggpage_plot(aes(fill = long_word)) + 106 | labs(title = "Longer words throughout The Tinder-box") + 107 | scale_fill_manual(values = c("grey70", "blue"), 108 | labels = c("8 or less", "9 or more"), 109 | name = "Word length") 110 | ``` 111 | 112 | ![](man/figures/README-unnamed-chunk-6-1.png) 113 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | destination: docs 2 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # DO NOT CHANGE the "init" and "install" sections below 2 | 3 | # Download script file from GitHub 4 | init: 5 | ps: | 6 | $ErrorActionPreference = "Stop" 7 | Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" 8 | Import-Module '..\appveyor-tool.ps1' 9 | 10 | install: 11 | ps: Bootstrap 12 | 13 | cache: 14 | - C:\RLibrary 15 | 16 | # Adapt as necessary starting from here 17 | 18 | build_script: 19 | - travis-tool.sh install_deps 20 | 21 | test_script: 22 | - travis-tool.sh run_tests 23 | 24 | on_failure: 25 | - 7z a failure.zip *.Rcheck\* 26 | - appveyor PushArtifact failure.zip 27 | 28 | artifacts: 29 | - path: '*.Rcheck\**\*.log' 30 | name: Logs 31 | 32 | - path: '*.Rcheck\**\*.out' 33 | name: Logs 34 | 35 | - path: '*.Rcheck\**\*.fail' 36 | name: Logs 37 | 38 | - path: '*.Rcheck\**\*.Rout' 39 | name: Logs 40 | 41 | - path: '\*_*.tar.gz' 42 | name: Bits 43 | 44 | - path: '\*_*.zip' 45 | name: Bits 46 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | patch: 10 | default: 11 | target: auto 12 | threshold: 1% 13 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Resubmission 2 | This is a resubmission. In this version I have: 3 | 4 | * Reduced the size of the tarball. 5 | 6 | ## Test environments 7 | * local OS X install, R 3.6.0 8 | * ubuntu 14.04 (on travis-ci), R 3.6.0 9 | * win-builder (devel and release) 10 | 11 | ## R CMD check results 12 | 13 | 0 errors | 0 warnings | 0 note 14 | -------------------------------------------------------------------------------- /data-raw/tinderbow_paragraph.R: -------------------------------------------------------------------------------- 1 | library(tidyverse) 2 | library(ggpage) 3 | tinderbox_paragraph <- tinderbox %>% 4 | mutate(split = dplyr::lag(stringr::str_length(text) < 20, default = FALSE), 5 | paragraph = cumsum(split)) %>% 6 | dplyr::select(text, paragraph) %>% 7 | nest(text) %>% 8 | mutate(text = purrr::map(data, unlist), 9 | text = purrr::map_chr(text, paste, collapse = " ")) %>% 10 | select(text) 11 | -------------------------------------------------------------------------------- /data/tinderbox.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/data/tinderbox.rda -------------------------------------------------------------------------------- /data/tinderbox_paragraph.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/data/tinderbox_paragraph.rda -------------------------------------------------------------------------------- /docs/LICENSE-text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | License • ggpage 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 | 55 | 56 | 57 | 58 | 59 | 60 |
61 |
62 | 117 | 118 | 119 |
120 | 121 |
122 |
123 | 126 | 127 |
YEAR: 2017
128 | COPYRIGHT HOLDER: Emil Hvitfeldt
129 | 
130 | 131 |
132 | 133 |
134 | 135 | 136 |
137 | 140 | 141 |
142 |

Site built with pkgdown 1.3.0.

143 |
144 |
145 |
146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /docs/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-1-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-1-2.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-1-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-1-3.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-1-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-1-4.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-5-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-5-2.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-5-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-5-3.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-5-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-5-4.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-5-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-5-5.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-5-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-5-6.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-5-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-5-7.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-5-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-5-8.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/different-features_files/figure-html/unnamed-chunk-7-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/articles/different-features_files/figure-html/unnamed-chunk-7-2.png -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Articles • ggpage 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 | 55 | 56 | 57 | 58 | 59 | 60 |
61 |
62 | 117 | 118 | 119 |
120 | 121 |
122 |
123 | 126 | 127 |
128 |

All vignettes

129 |

130 | 131 | 134 |
135 |
136 |
137 | 138 |
139 | 142 | 143 |
144 |

Site built with pkgdown 1.3.0.

145 |
146 |
147 |
148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Authors • ggpage 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 | 55 | 56 | 57 | 58 | 59 | 60 |
61 |
62 | 117 | 118 | 119 |
120 | 121 |
122 |
123 | 126 | 127 |
    128 |
  • 129 |

    Emil Hvitfeldt. Author, maintainer. 130 |

    131 |
  • 132 |
133 | 134 |
135 | 136 |
137 | 138 | 139 |
140 | 143 | 144 |
145 |

Site built with pkgdown 1.3.0.

146 |
147 |
148 |
149 | 150 | 151 | 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /docs/docsearch.css: -------------------------------------------------------------------------------- 1 | /* Docsearch -------------------------------------------------------------- */ 2 | /* 3 | Source: https://github.com/algolia/docsearch/ 4 | License: MIT 5 | */ 6 | 7 | .algolia-autocomplete { 8 | display: block; 9 | -webkit-box-flex: 1; 10 | -ms-flex: 1; 11 | flex: 1 12 | } 13 | 14 | .algolia-autocomplete .ds-dropdown-menu { 15 | width: 100%; 16 | min-width: none; 17 | max-width: none; 18 | padding: .75rem 0; 19 | background-color: #fff; 20 | background-clip: padding-box; 21 | border: 1px solid rgba(0, 0, 0, .1); 22 | box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); 23 | } 24 | 25 | @media (min-width:768px) { 26 | .algolia-autocomplete .ds-dropdown-menu { 27 | width: 175% 28 | } 29 | } 30 | 31 | .algolia-autocomplete .ds-dropdown-menu::before { 32 | display: none 33 | } 34 | 35 | .algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { 36 | padding: 0; 37 | background-color: rgb(255,255,255); 38 | border: 0; 39 | max-height: 80vh; 40 | } 41 | 42 | .algolia-autocomplete .ds-dropdown-menu .ds-suggestions { 43 | margin-top: 0 44 | } 45 | 46 | .algolia-autocomplete .algolia-docsearch-suggestion { 47 | padding: 0; 48 | overflow: visible 49 | } 50 | 51 | .algolia-autocomplete .algolia-docsearch-suggestion--category-header { 52 | padding: .125rem 1rem; 53 | margin-top: 0; 54 | font-size: 1.3em; 55 | font-weight: 500; 56 | color: #00008B; 57 | border-bottom: 0 58 | } 59 | 60 | .algolia-autocomplete .algolia-docsearch-suggestion--wrapper { 61 | float: none; 62 | padding-top: 0 63 | } 64 | 65 | .algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { 66 | float: none; 67 | width: auto; 68 | padding: 0; 69 | text-align: left 70 | } 71 | 72 | .algolia-autocomplete .algolia-docsearch-suggestion--content { 73 | float: none; 74 | width: auto; 75 | padding: 0 76 | } 77 | 78 | .algolia-autocomplete .algolia-docsearch-suggestion--content::before { 79 | display: none 80 | } 81 | 82 | .algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { 83 | padding-top: .75rem; 84 | margin-top: .75rem; 85 | border-top: 1px solid rgba(0, 0, 0, .1) 86 | } 87 | 88 | .algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { 89 | display: block; 90 | padding: .1rem 1rem; 91 | margin-bottom: 0.1; 92 | font-size: 1.0em; 93 | font-weight: 400 94 | /* display: none */ 95 | } 96 | 97 | .algolia-autocomplete .algolia-docsearch-suggestion--title { 98 | display: block; 99 | padding: .25rem 1rem; 100 | margin-bottom: 0; 101 | font-size: 0.9em; 102 | font-weight: 400 103 | } 104 | 105 | .algolia-autocomplete .algolia-docsearch-suggestion--text { 106 | padding: 0 1rem .5rem; 107 | margin-top: -.25rem; 108 | font-size: 0.8em; 109 | font-weight: 400; 110 | line-height: 1.25 111 | } 112 | 113 | .algolia-autocomplete .algolia-docsearch-footer { 114 | width: 110px; 115 | height: 20px; 116 | z-index: 3; 117 | margin-top: 10.66667px; 118 | float: right; 119 | font-size: 0; 120 | line-height: 0; 121 | } 122 | 123 | .algolia-autocomplete .algolia-docsearch-footer--logo { 124 | background-image: url("data:image/svg+xml;utf8,"); 125 | background-repeat: no-repeat; 126 | background-position: 50%; 127 | background-size: 100%; 128 | overflow: hidden; 129 | text-indent: -9000px; 130 | width: 100%; 131 | height: 100%; 132 | display: block; 133 | transform: translate(-8px); 134 | } 135 | 136 | .algolia-autocomplete .algolia-docsearch-suggestion--highlight { 137 | color: #FF8C00; 138 | background: rgba(232, 189, 54, 0.1) 139 | } 140 | 141 | 142 | .algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { 143 | box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) 144 | } 145 | 146 | .algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { 147 | background-color: rgba(192, 192, 192, .15) 148 | } 149 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/favicon-16x16.png -------------------------------------------------------------------------------- /docs/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/favicon-32x32.png -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/favicon.ico -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/logo.png -------------------------------------------------------------------------------- /docs/news/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Changelog • ggpage 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 | 55 | 56 | 57 | 58 | 59 | 60 |
61 |
62 | 117 | 118 | 119 |
120 | 121 |
122 |
123 | 127 | 128 |
129 |

130 | ggpage 0.2.2 2018-07-27 131 |

132 |
    133 |
  • Added a NEWS.md file to track changes to the package.
  • 134 |
135 |
136 |
137 | 138 | 146 | 147 |
148 | 149 |
150 | 153 | 154 |
155 |

Site built with pkgdown 1.3.0.

156 |
157 |
158 |
159 | 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /docs/pkgdown.css: -------------------------------------------------------------------------------- 1 | /* Sticky footer */ 2 | 3 | /** 4 | * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ 5 | * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css 6 | * 7 | * .Site -> body > .container 8 | * .Site-content -> body > .container .row 9 | * .footer -> footer 10 | * 11 | * Key idea seems to be to ensure that .container and __all its parents__ 12 | * have height set to 100% 13 | * 14 | */ 15 | 16 | html, body { 17 | height: 100%; 18 | } 19 | 20 | body > .container { 21 | display: flex; 22 | height: 100%; 23 | flex-direction: column; 24 | 25 | padding-top: 60px; 26 | } 27 | 28 | body > .container .row { 29 | flex: 1 0 auto; 30 | } 31 | 32 | footer { 33 | margin-top: 45px; 34 | padding: 35px 0 36px; 35 | border-top: 1px solid #e5e5e5; 36 | color: #666; 37 | display: flex; 38 | flex-shrink: 0; 39 | } 40 | footer p { 41 | margin-bottom: 0; 42 | } 43 | footer div { 44 | flex: 1; 45 | } 46 | footer .pkgdown { 47 | text-align: right; 48 | } 49 | footer p { 50 | margin-bottom: 0; 51 | } 52 | 53 | img.icon { 54 | float: right; 55 | } 56 | 57 | img { 58 | max-width: 100%; 59 | } 60 | 61 | /* Fix bug in bootstrap (only seen in firefox) */ 62 | summary { 63 | display: list-item; 64 | } 65 | 66 | /* Typographic tweaking ---------------------------------*/ 67 | 68 | .contents .page-header { 69 | margin-top: calc(-60px + 1em); 70 | } 71 | 72 | /* Section anchors ---------------------------------*/ 73 | 74 | a.anchor { 75 | margin-left: -30px; 76 | display:inline-block; 77 | width: 30px; 78 | height: 30px; 79 | visibility: hidden; 80 | 81 | background-image: url(./link.svg); 82 | background-repeat: no-repeat; 83 | background-size: 20px 20px; 84 | background-position: center center; 85 | } 86 | 87 | .hasAnchor:hover a.anchor { 88 | visibility: visible; 89 | } 90 | 91 | @media (max-width: 767px) { 92 | .hasAnchor:hover a.anchor { 93 | visibility: hidden; 94 | } 95 | } 96 | 97 | 98 | /* Fixes for fixed navbar --------------------------*/ 99 | 100 | .contents h1, .contents h2, .contents h3, .contents h4 { 101 | padding-top: 60px; 102 | margin-top: -40px; 103 | } 104 | 105 | /* Static header placement on mobile devices */ 106 | @media (max-width: 767px) { 107 | .navbar-fixed-top { 108 | position: absolute; 109 | } 110 | .navbar { 111 | padding: 0; 112 | } 113 | } 114 | 115 | 116 | /* Sidebar --------------------------*/ 117 | 118 | #sidebar { 119 | margin-top: 30px; 120 | } 121 | #sidebar h2 { 122 | font-size: 1.5em; 123 | margin-top: 1em; 124 | } 125 | 126 | #sidebar h2:first-child { 127 | margin-top: 0; 128 | } 129 | 130 | #sidebar .list-unstyled li { 131 | margin-bottom: 0.5em; 132 | } 133 | 134 | .orcid { 135 | height: 16px; 136 | vertical-align: middle; 137 | } 138 | 139 | /* Reference index & topics ----------------------------------------------- */ 140 | 141 | .ref-index th {font-weight: normal;} 142 | 143 | .ref-index td {vertical-align: top;} 144 | .ref-index .icon {width: 40px;} 145 | .ref-index .alias {width: 40%;} 146 | .ref-index-icons .alias {width: calc(40% - 40px);} 147 | .ref-index .title {width: 60%;} 148 | 149 | .ref-arguments th {text-align: right; padding-right: 10px;} 150 | .ref-arguments th, .ref-arguments td {vertical-align: top;} 151 | .ref-arguments .name {width: 20%;} 152 | .ref-arguments .desc {width: 80%;} 153 | 154 | /* Nice scrolling for wide elements --------------------------------------- */ 155 | 156 | table { 157 | display: block; 158 | overflow: auto; 159 | } 160 | 161 | /* Syntax highlighting ---------------------------------------------------- */ 162 | 163 | pre { 164 | word-wrap: normal; 165 | word-break: normal; 166 | border: 1px solid #eee; 167 | } 168 | 169 | pre, code { 170 | background-color: #f8f8f8; 171 | color: #333; 172 | } 173 | 174 | pre code { 175 | overflow: auto; 176 | word-wrap: normal; 177 | white-space: pre; 178 | } 179 | 180 | pre .img { 181 | margin: 5px 0; 182 | } 183 | 184 | pre .img img { 185 | background-color: #fff; 186 | display: block; 187 | height: auto; 188 | } 189 | 190 | code a, pre a { 191 | color: #375f84; 192 | } 193 | 194 | a.sourceLine:hover { 195 | text-decoration: none; 196 | } 197 | 198 | .fl {color: #1514b5;} 199 | .fu {color: #000000;} /* function */ 200 | .ch,.st {color: #036a07;} /* string */ 201 | .kw {color: #264D66;} /* keyword */ 202 | .co {color: #888888;} /* comment */ 203 | 204 | .message { color: black; font-weight: bolder;} 205 | .error { color: orange; font-weight: bolder;} 206 | .warning { color: #6A0366; font-weight: bolder;} 207 | 208 | /* Clipboard --------------------------*/ 209 | 210 | .hasCopyButton { 211 | position: relative; 212 | } 213 | 214 | .btn-copy-ex { 215 | position: absolute; 216 | right: 0; 217 | top: 0; 218 | visibility: hidden; 219 | } 220 | 221 | .hasCopyButton:hover button.btn-copy-ex { 222 | visibility: visible; 223 | } 224 | 225 | /* mark.js ----------------------------*/ 226 | 227 | mark { 228 | background-color: rgba(255, 255, 51, 0.5); 229 | border-bottom: 2px solid rgba(255, 153, 51, 0.3); 230 | padding: 1px; 231 | } 232 | 233 | /* vertical spacing after htmlwidgets */ 234 | .html-widget { 235 | margin-bottom: 10px; 236 | } 237 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $("#sidebar") 6 | .stick_in_parent({offset_top: 40}) 7 | .on('sticky_kit:bottom', function(e) { 8 | $(this).parent().css('position', 'static'); 9 | }) 10 | .on('sticky_kit:unbottom', function(e) { 11 | $(this).parent().css('position', 'relative'); 12 | }); 13 | 14 | $('body').scrollspy({ 15 | target: '#sidebar', 16 | offset: 60 17 | }); 18 | 19 | $('[data-toggle="tooltip"]').tooltip(); 20 | 21 | var cur_path = paths(location.pathname); 22 | var links = $("#navbar ul li a"); 23 | var max_length = -1; 24 | var pos = -1; 25 | for (var i = 0; i < links.length; i++) { 26 | if (links[i].getAttribute("href") === "#") 27 | continue; 28 | // Ignore external links 29 | if (links[i].host !== location.host) 30 | continue; 31 | 32 | var nav_path = paths(links[i].pathname); 33 | 34 | var length = prefix_length(nav_path, cur_path); 35 | if (length > max_length) { 36 | max_length = length; 37 | pos = i; 38 | } 39 | } 40 | 41 | // Add class to parent
  • , and enclosing
  • if in dropdown 42 | if (pos >= 0) { 43 | var menu_anchor = $(links[pos]); 44 | menu_anchor.parent().addClass("active"); 45 | menu_anchor.closest("li.dropdown").addClass("active"); 46 | } 47 | }); 48 | 49 | function paths(pathname) { 50 | var pieces = pathname.split("/"); 51 | pieces.shift(); // always starts with / 52 | 53 | var end = pieces[pieces.length - 1]; 54 | if (end === "index.html" || end === "") 55 | pieces.pop(); 56 | return(pieces); 57 | } 58 | 59 | // Returns -1 if not found 60 | function prefix_length(needle, haystack) { 61 | if (needle.length > haystack.length) 62 | return(-1); 63 | 64 | // Special case for length-0 haystack, since for loop won't run 65 | if (haystack.length === 0) { 66 | return(needle.length === 0 ? 0 : -1); 67 | } 68 | 69 | for (var i = 0; i < haystack.length; i++) { 70 | if (needle[i] != haystack[i]) 71 | return(i); 72 | } 73 | 74 | return(haystack.length); 75 | } 76 | 77 | /* Clipboard --------------------------*/ 78 | 79 | function changeTooltipMessage(element, msg) { 80 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 81 | element.setAttribute('data-original-title', msg); 82 | $(element).tooltip('show'); 83 | element.setAttribute('data-original-title', tooltipOriginalTitle); 84 | } 85 | 86 | if(ClipboardJS.isSupported()) { 87 | $(document).ready(function() { 88 | var copyButton = ""; 89 | 90 | $(".examples, div.sourceCode").addClass("hasCopyButton"); 91 | 92 | // Insert copy buttons: 93 | $(copyButton).prependTo(".hasCopyButton"); 94 | 95 | // Initialize tooltips: 96 | $('.btn-copy-ex').tooltip({container: 'body'}); 97 | 98 | // Initialize clipboard: 99 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 100 | text: function(trigger) { 101 | return trigger.parentNode.textContent; 102 | } 103 | }); 104 | 105 | clipboardBtnCopies.on('success', function(e) { 106 | changeTooltipMessage(e.trigger, 'Copied!'); 107 | e.clearSelection(); 108 | }); 109 | 110 | clipboardBtnCopies.on('error', function() { 111 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 112 | }); 113 | }); 114 | } 115 | })(window.jQuery || window.$) 116 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 1.19.2.1 2 | pkgdown: 1.3.0 3 | pkgdown_sha: ~ 4 | articles: 5 | different-features: different-features.html 6 | 7 | -------------------------------------------------------------------------------- /docs/reference/break_help.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Repeating of indexes — break_help • ggpage 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 | 57 | 58 | 59 | 60 | 61 | 62 |
    63 |
    64 | 119 | 120 | 121 |
    122 | 123 |
    124 |
    125 | 130 | 131 |
    132 | 133 |

    Repeating of indexes

    134 | 135 |
    136 | 137 |
    break_help(x)
    138 | 139 |

    Arguments

    140 | 141 | 142 | 143 | 144 | 145 | 146 |
    x

    Numerical, vector.

    147 | 148 |

    Value

    149 | 150 |

    Numerical.

    151 | 152 | 153 |

    Examples

    154 |
    break_help(c(1, 2, 3))
    #> [1] 1 2 2 3 3 3
    break_help(c(6, 8, 23, 50))
    #> [1] 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 155 | #> [39] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 156 | #> [77] 4 4 4 4 4 4 4 4 4 4 4
    157 |
    158 | 169 |
    170 | 171 |
    172 | 175 | 176 |
    177 |

    Site built with pkgdown 1.3.0.

    178 |
    179 |
    180 |
    181 | 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /docs/reference/figures/README-readmegif-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/figures/README-readmegif-1.gif -------------------------------------------------------------------------------- /docs/reference/figures/README-unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/figures/README-unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/reference/figures/README-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/figures/README-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/reference/figures/README-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/figures/README-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/reference/figures/README-unnamed-chunk-6-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/figures/README-unnamed-chunk-6-1.gif -------------------------------------------------------------------------------- /docs/reference/figures/README-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/figures/README-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/reference/figures/README-unnamed-chunk-7-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/figures/README-unnamed-chunk-7-1.gif -------------------------------------------------------------------------------- /docs/reference/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/figures/logo.png -------------------------------------------------------------------------------- /docs/reference/ggpage_build-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_build-1.png -------------------------------------------------------------------------------- /docs/reference/ggpage_build-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_build-2.png -------------------------------------------------------------------------------- /docs/reference/ggpage_build-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_build-3.png -------------------------------------------------------------------------------- /docs/reference/ggpage_build-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_build-4.png -------------------------------------------------------------------------------- /docs/reference/ggpage_build-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_build-5.png -------------------------------------------------------------------------------- /docs/reference/ggpage_build-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_build-6.png -------------------------------------------------------------------------------- /docs/reference/ggpage_build-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_build-7.png -------------------------------------------------------------------------------- /docs/reference/ggpage_plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_plot-1.png -------------------------------------------------------------------------------- /docs/reference/ggpage_plot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_plot-2.png -------------------------------------------------------------------------------- /docs/reference/ggpage_plot-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_plot-3.png -------------------------------------------------------------------------------- /docs/reference/ggpage_plot-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_plot-4.png -------------------------------------------------------------------------------- /docs/reference/ggpage_plot-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_plot-5.png -------------------------------------------------------------------------------- /docs/reference/ggpage_plot-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_plot-6.png -------------------------------------------------------------------------------- /docs/reference/ggpage_plot-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_plot-7.png -------------------------------------------------------------------------------- /docs/reference/ggpage_quick-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_quick-1.png -------------------------------------------------------------------------------- /docs/reference/ggpage_quick-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_quick-2.png -------------------------------------------------------------------------------- /docs/reference/ggpage_quick-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/docs/reference/ggpage_quick-3.png -------------------------------------------------------------------------------- /docs/reference/ggpage_quick.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Creates a quick visualization of the page layout — ggpage_quick • ggpage 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 | 57 | 58 | 59 | 60 | 61 | 62 |
    63 |
    64 | 119 | 120 | 121 |
    122 | 123 |
    124 |
    125 | 130 | 131 |
    132 | 133 |

    Creates a quick visualization of the page layout

    134 | 135 |
    136 | 137 |
    ggpage_quick(book, lpp = 25, character_height = 3,
    138 |   vertical_space = 1, x_space_pages = 10, y_space_pages = 10,
    139 |   nrow = NULL, ncol = NULL, bycol = TRUE)
    140 | 141 |

    Arguments

    142 | 143 | 144 | 145 | 146 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 174 | 175 | 176 | 177 | 179 | 180 | 181 | 182 | 184 | 185 |
    book

    Character or data.frame. Can either have each element be a 147 | separate line or having each element being separate words.

    lpp

    Numeric. Lines Per Page. Number of lines allocated for each page.

    character_height

    Numeric. Relative size of the height of each letter 156 | compared to its width.

    vertical_space

    Numeric. Distance between each lines vertically.

    x_space_pages

    Numeric. Distance between pages along the x-axis.

    y_space_pages

    Numeric. Distance between pages along the y-axis.

    nrow

    Numeric. Number of rows of pages, if omitted defaults to square 173 | layout.

    ncol

    Numeric. Number of columns of pages, if omitted defaults to 178 | square layout.

    bycol

    Logical. If TRUE (the default) the matrix is filled by 183 | columns, otherwise the matrix is filled by rows.

    186 | 187 |

    Value

    188 | 189 |

    A ggplot object with the given visualization.

    190 | 191 | 192 |

    Examples

    193 |
    library(dplyr) 194 | library(stringr) 195 | library(ggplot2) 196 | library(tidytext) 197 | library(ggpage) 198 | # quick 199 | ## data.frame with full lines 200 | ggpage_quick(tinderbox)
    ## vector with full lines 201 | ggpage_quick(tinderbox %>% 202 | pull(text))
    #> Error in check_input(x): Input must be a character vector of any length or a list of character 203 | #> vectors, each of which has a length of 1.
    ## data.frame with single words 204 | ggpage_quick(tinderbox %>% 205 | unnest_tokens(text, text))
    #> Error in check_input(x): Input must be a character vector of any length or a list of character 206 | #> vectors, each of which has a length of 1.
    ## vector with single words 207 | ggpage_quick(tinderbox %>% 208 | unnest_tokens(text, text) %>% 209 | pull(text))
    #> Error in check_input(x): Input must be a character vector of any length or a list of character 210 | #> vectors, each of which has a length of 1.
    211 | # nrow and ncol 212 | ggpage_quick(tinderbox, nrow = 2)
    ggpage_quick(tinderbox, ncol = 2)
    213 |
    214 | 225 |
    226 | 227 |
    228 | 231 | 232 |
    233 |

    Site built with pkgdown 1.3.0.

    234 |
    235 |
    236 |
    237 | 238 | 239 | 240 | 241 | 242 | 243 | -------------------------------------------------------------------------------- /docs/reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Function reference • ggpage 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 | 55 | 56 | 57 | 58 | 59 | 60 |
    61 |
    62 | 117 | 118 | 119 |
    120 | 121 |
    122 |
    123 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 141 | 142 | 143 | 144 | 147 | 148 | 149 | 150 | 153 | 154 | 155 | 156 | 159 | 160 | 161 | 162 | 165 | 166 | 167 | 168 | 171 | 172 | 173 | 174 | 177 | 178 | 179 | 180 | 183 | 184 | 185 | 186 | 189 | 190 | 191 | 192 | 195 | 196 | 197 | 198 | 201 | 202 | 203 | 204 | 207 | 208 | 209 | 210 | 213 | 214 | 215 | 216 |
    138 |

    All functions

    139 |

    140 |
    145 |

    break_help()

    146 |

    Repeating of indexes

    151 |

    ggpage_build()

    152 |

    Creates a data frame for further analysis and plotting

    157 |

    ggpage_plot()

    158 |

    Creates a visualization from the ggpage_build output

    163 |

    ggpage_quick()

    164 |

    Creates a quick visualization of the page layout

    169 |

    line_align()

    170 |

    Adjust lines

    175 |

    nest_paragraphs()

    176 |

    converts paragraph tokens into line tokens

    181 |

    page_liner()

    182 |

    Add line number within pages

    187 |

    paper_shape()

    188 |

    Identify the edges of the paper of each page

    193 |

    para_index()

    194 |

    paragraph split

    199 |

    tinderbox

    200 |

    The tinder-box by H.C. Andersen

    205 |

    tinderbox_paragraph

    206 |

    The tinder-box by H.C. Andersen

    211 |

    word_to_line()

    212 |

    Internal function for converting words to lines

    217 |
    218 | 219 | 225 |
    226 | 227 |
    228 | 231 | 232 |
    233 |

    Site built with pkgdown 1.3.0.

    234 |
    235 |
    236 |
    237 | 238 | 239 | 240 | 241 | 242 | 243 | -------------------------------------------------------------------------------- /docs/reference/line_align.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Adjust lines — line_align • ggpage 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 | 57 | 58 | 59 | 60 | 61 | 62 |
    63 |
    64 | 119 | 120 | 121 |
    122 | 123 |
    124 |
    125 | 130 | 131 |
    132 | 133 |

    Adjust lines

    134 | 135 |
    136 | 137 |
    line_align(line, max_length, type)
    138 | 139 |

    Arguments

    140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 |
    line

    data.frame

    max_length

    numerical. number of letters allowed on a line.

    type

    Type of line alignment. Must be one of "left", "right" or "both".

    155 | 156 |

    Value

    157 | 158 |

    data.frame

    159 | 160 | 161 |
    162 | 171 |
    172 | 173 |
    174 | 177 | 178 |
    179 |

    Site built with pkgdown 1.3.0.

    180 |
    181 |
    182 |
    183 | 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /docs/reference/nest_paragraphs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | converts paragraph tokens into line tokens — nest_paragraphs • ggpage 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 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 62 | 63 |
    64 |
    65 | 120 | 121 | 122 |
    123 | 124 |
    125 |
    126 | 131 | 132 |
    133 | 134 |

    extents the str_wrap() function from the stringr package to work with longer 135 | strings.

    136 | 137 |
    138 | 139 |
    nest_paragraphs(data, input, ...)
    140 | 141 |

    Arguments

    142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 |
    data

    data.frame. With one paragraph per row.

    input

    column that gets split as string or symbol.

    ...

    Extra arguments passed to str_wrap.

    157 | 158 |

    Value

    159 | 160 |

    data.frame.

    161 | 162 | 163 |
    164 | 173 |
    174 | 175 |
    176 | 179 | 180 |
    181 |

    Site built with pkgdown 1.3.0.

    182 |
    183 |
    184 |
    185 | 186 | 187 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /docs/reference/page_liner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Add line number within pages — page_liner • ggpage 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 | 57 | 58 | 59 | 60 | 61 | 62 |
    63 |
    64 | 119 | 120 | 121 |
    122 | 123 |
    124 |
    125 | 130 | 131 |
    132 | 133 |

    Add line number within pages

    134 | 135 |
    136 | 137 |
    page_liner(data)
    138 | 139 |

    Arguments

    140 | 141 | 142 | 143 | 144 | 145 | 146 |
    data

    data.frame

    147 | 148 |

    Value

    149 | 150 |

    data.frame

    151 | 152 | 153 |
    154 | 163 |
    164 | 165 |
    166 | 169 | 170 |
    171 |

    Site built with pkgdown 1.3.0.

    172 |
    173 |
    174 |
    175 | 176 | 177 | 178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /docs/reference/paper_shape.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Identify the edges of the paper of each page — paper_shape • ggpage 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 | 57 | 58 | 59 | 60 | 61 | 62 |
    63 |
    64 | 119 | 120 | 121 |
    122 | 123 |
    124 |
    125 | 130 | 131 |
    132 | 133 |

    Identify the edges of the paper of each page

    134 | 135 |
    136 | 137 |
    paper_shape(data)
    138 | 139 |

    Arguments

    140 | 141 | 142 | 143 | 144 | 145 | 146 |
    data

    data.frame created by ggpage_build.

    147 | 148 |

    Value

    149 | 150 |

    data.frame,

    151 | 152 | 153 |

    Examples

    154 |
    paper_shape(ggpage_build(tinderbox))
    #> # A tibble: 9 x 5 155 | #> page xmin xmax ymin ymax 156 | #> <int> <dbl> <dbl> <dbl> <dbl> 157 | #> 1 1 168 90 -114 -213 158 | #> 2 2 167 90 -224 -323 159 | #> 3 3 168 90 -334 -433 160 | #> 4 4 259 180 -114 -213 161 | #> 5 5 258 180 -224 -323 162 | #> 6 6 259 180 -334 -433 163 | #> 7 7 349 270 -114 -213 164 | #> 8 8 349 270 -224 -323 165 | #> 9 9 348 270 -334 -377
    166 |
    167 | 178 |
    179 | 180 |
    181 | 184 | 185 |
    186 |

    Site built with pkgdown 1.3.0.

    187 |
    188 |
    189 |
    190 | 191 | 192 | 193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /docs/reference/para_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | paragraph split — para_index • ggpage 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 | 57 | 58 | 59 | 60 | 61 | 62 |
    63 |
    64 | 119 | 120 | 121 |
    122 | 123 |
    124 |
    125 | 130 | 131 |
    132 | 133 |

    Converts a word vector into a line vector with variable paragraph lengths.

    134 | 135 |
    136 | 137 |
    para_index(n, FUN, ...)
    138 | 139 |

    Arguments

    140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 |
    n

    Numeric. Numbers of words.

    FUN

    Numeric. how many words to split whole string by.

    ...

    Extra arguments.

    155 | 156 |

    Value

    157 | 158 |

    Numeric. paragraph indicator.

    159 | 160 |

    Details

    161 | 162 |

    FUN most be a function that takes in a number n and returns a vector of 163 | natural numbers.

    164 | 165 | 166 |
    167 | 178 |
    179 | 180 |
    181 | 184 | 185 |
    186 |

    Site built with pkgdown 1.3.0.

    187 |
    188 |
    189 |
    190 | 191 | 192 | 193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /docs/reference/pipe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Pipe operator — %>% • ggpage 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 | 57 | 58 | 59 | 60 | 61 | 62 |
    63 |
    64 | 119 | 120 | 121 |
    122 | 123 |
    124 |
    125 | 130 | 131 |
    132 | 133 |

    See magrittr::%>% for details.

    134 | 135 |
    136 | 137 |
    lhs %>% rhs
    138 | 139 | 140 |
    141 | 147 |
    148 | 149 |
    150 | 153 | 154 |
    155 |

    Site built with pkgdown 1.3.0.

    156 |
    157 |
    158 |
    159 | 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /docs/reference/tinderbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | The tinder-box by H.C. Andersen — tinderbox • ggpage 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 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 60 | 61 | 62 | 63 | 64 | 65 |
    66 |
    67 | 122 | 123 | 124 |
    125 | 126 |
    127 |
    128 | 133 | 134 |
    135 | 136 |

    A tidy data.frame containing the entire story of The tinder-box by H.C. 137 | Andersen with two columns: text which contains the text of the 138 | fairy tale divided into elements of up to about 80 characters each and 139 | book giving the name of the fairy tale in question.

    140 | 141 |
    142 | 143 |
    tinderbox
    144 | 145 |

    Format

    146 | 147 |

    A data frame with 211 rows and 2 variables:

    148 |
    text

    character string up to 80 characters each

    149 |
    book

    name of the fairy tale

    150 | ... 151 |
    152 | 153 | 154 |
    155 | 163 |
    164 | 165 |
    166 | 169 | 170 |
    171 |

    Site built with pkgdown 1.3.0.

    172 |
    173 |
    174 |
    175 | 176 | 177 | 178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /docs/reference/tinderbox_paragraph.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | The tinder-box by H.C. Andersen — tinderbox_paragraph • ggpage 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 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 64 |
    65 |
    66 | 121 | 122 | 123 |
    124 | 125 |
    126 |
    127 | 132 | 133 |
    134 | 135 |

    A tidy data.frame containing the entire story of The tinder-box by H.C. 136 | Andersen with two columns: text which contains the text of the 137 | fairy tale divided into paragraphs.

    138 | 139 |
    140 | 141 |
    tinderbox_paragraph
    142 | 143 |

    Format

    144 | 145 |

    A data frame with 11 rows and 1 variables:

    146 |
    text

    character string up to 80 characters each

    147 | ... 148 |
    149 | 150 | 151 |
    152 | 160 |
    161 | 162 |
    163 | 166 | 167 |
    168 |

    Site built with pkgdown 1.3.0.

    169 |
    170 |
    171 |
    172 | 173 | 174 | 175 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /docs/reference/word_to_line.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Internal function for converting words to lines — word_to_line • ggpage 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 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 62 | 63 |
    64 |
    65 | 120 | 121 | 122 |
    123 | 124 |
    125 |
    126 | 131 | 132 |
    133 | 134 |

    extents the str_wrap() function from the stringr package to work with longer 135 | strings.

    136 | 137 |
    138 | 139 |
    word_to_line(words, wot_number = 1000)
    140 | 141 |

    Arguments

    142 | 143 | 144 | 145 | 146 | 148 | 149 | 150 | 151 | 152 | 153 |
    words

    data.frame. Where each row is a separate word words with the 147 | column name text.

    wot_number

    Numeric. how many words to split whole string by.

    154 | 155 |

    Value

    156 | 157 |

    Character. have each element be a separate line.

    158 | 159 | 160 |
    161 | 170 |
    171 | 172 | 181 |
    182 | 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /ggpage.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | -------------------------------------------------------------------------------- /man/break_help.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{break_help} 4 | \alias{break_help} 5 | \title{Repeating of indexes} 6 | \usage{ 7 | break_help(x) 8 | } 9 | \arguments{ 10 | \item{x}{Numerical, vector.} 11 | } 12 | \value{ 13 | Numerical. 14 | } 15 | \description{ 16 | Repeating of indexes 17 | } 18 | \examples{ 19 | break_help(c(1, 2, 3)) 20 | break_help(c(6, 8, 23, 50)) 21 | } 22 | -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/man/figures/README-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/man/figures/README-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/man/figures/logo.png -------------------------------------------------------------------------------- /man/ggpage_build.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ggpage_build.R 3 | \name{ggpage_build} 4 | \alias{ggpage_build} 5 | \title{Creates a data frame for further analysis and plotting} 6 | \usage{ 7 | ggpage_build(book, lpp = 25, character_height = 3, 8 | vertical_space = 1, x_space_pages = 10, y_space_pages = 10, 9 | nrow = NULL, ncol = NULL, bycol = TRUE, wtl = NULL, 10 | para.fun = NULL, page.col = NULL, align = "left", line.max = 80, 11 | ...) 12 | } 13 | \arguments{ 14 | \item{book}{Character or data.frame. Can either have each element be a 15 | separate line or having each element being separate words.} 16 | 17 | \item{lpp}{Numeric. Lines Per Page. Number of lines allocated for each page.} 18 | 19 | \item{character_height}{Numeric. Relative size of the height of each letter 20 | compared to its width.} 21 | 22 | \item{vertical_space}{Numeric. Distance between each lines vertically.} 23 | 24 | \item{x_space_pages}{Numeric. Distance between pages along the x-axis.} 25 | 26 | \item{y_space_pages}{Numeric. Distance between pages along the y-axis.} 27 | 28 | \item{nrow}{Numeric. Number of rows of pages, if omitted defaults to square 29 | layout.} 30 | 31 | \item{ncol}{Numeric. Number of columns of pages, if omitted defaults to 32 | square layout.} 33 | 34 | \item{bycol}{Logical. If TRUE (the default) the matrix is filled by 35 | columns, otherwise the matrix is filled by rows.} 36 | 37 | \item{wtl}{logical. If TRUE will convert single word vector into a vector 38 | with full lines. (defaults to FALSE).} 39 | 40 | \item{para.fun}{Function that generates random numbers to determine number 41 | of word in each paragraph.} 42 | 43 | \item{page.col}{column to split the pages by.} 44 | 45 | \item{align}{Type of line alignment. Must be one of "left", "right" or "both".} 46 | 47 | \item{line.max}{Maximal number of characters per line. Defaults to 80.} 48 | 49 | \item{...}{Extra arguments.} 50 | } 51 | \value{ 52 | `data.frame` containing the following columns: 53 | \itemize{ 54 | \item `word`: Character. The words of the text. 55 | \item `page`: Integer. Page number. 56 | \item `line`: Integer. Line number within the page. 57 | \item `xmin`: Numeric. Border of rectangle, used by \code{ggpage_plot} do not 58 | alter. 59 | \item `xmax`: Numeric. Border of rectangle, used by \code{ggpage_plot} do not 60 | alter. 61 | \item `ymin`: Numeric. Border of rectangle, used by \code{ggpage_plot} do not 62 | alter. 63 | \item `ymax`: Numeric. Border of rectangle, used by \code{ggpage_plot} do not 64 | alter. 65 | } 66 | } 67 | \description{ 68 | This function can be used in combination with \code{ggpage_plot} to get the 69 | same result as \code{ggpage_quick}. However by splitting the data.frame 70 | construction and plotting we are able to do intermediate analysis which 71 | can be included in the visualization. 72 | } 73 | \details{ 74 | The text MUST be presented in a column named text. 75 | } 76 | \examples{ 77 | \donttest{ 78 | library(dplyr) 79 | library(stringr) 80 | library(ggplot2) 81 | library(tidytext) 82 | library(ggpage) 83 | # build and plot 84 | ## data.frame with full lines 85 | ggpage_build(tinderbox) \%>\% 86 | ggpage_plot() 87 | ## vector with full lines 88 | ggpage_build(book = tinderbox \%>\% 89 | pull(text)) \%>\% 90 | ggpage_plot() 91 | ## data.frame with single words 92 | ggpage_build(tinderbox) \%>\% 93 | unnest_tokens(text, word) \%>\% 94 | ggpage_plot() 95 | ## vector with single words 96 | ggpage_build(tinderbox \%>\% 97 | unnest_tokens(text, text) \%>\% 98 | pull(text)) \%>\% 99 | ggpage_plot() 100 | 101 | # nrow and ncol 102 | ggpage_build(tinderbox, nrow = 2) \%>\% 103 | ggpage_plot() 104 | ggpage_build(tinderbox, ncol = 2) \%>\% 105 | ggpage_plot() 106 | 107 | # Include analysis within 108 | ggpage_build(tinderbox) \%>\% 109 | mutate(word_length = str_length(word)) \%>\% 110 | ggpage_plot(aes(fill = word_length)) 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /man/ggpage_plot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ggpage_plot.R 3 | \name{ggpage_plot} 4 | \alias{ggpage_plot} 5 | \title{Creates a visualization from the ggpage_build output} 6 | \usage{ 7 | ggpage_plot(data, mapping = ggplot2::aes(), paper.show = FALSE, 8 | paper.color = "grey90", paper.alpha = 1, paper.limits = 3, 9 | page.number = character(1), page.number.x = 3, page.number.y = 3) 10 | } 11 | \arguments{ 12 | \item{data}{data.frame. Expects output from \code{ggpage_build} with 13 | optional intermediate analysis.} 14 | 15 | \item{mapping}{Default list of aesthetic mappings to use for plot to be 16 | handed to internal \code{ggplot} call.} 17 | 18 | \item{paper.show}{Shows the paper underneath the text.} 19 | 20 | \item{paper.color}{Color of the pages. Needs to be of length 1 or the same 21 | as the number of pages.} 22 | 23 | \item{paper.alpha}{Alpha of the pages. Needs to be of length 1 or the same 24 | as the number of pages.} 25 | 26 | \item{paper.limits}{Numerical. Extends the edges of the paper in all 27 | directions.} 28 | 29 | \item{page.number}{Position of the page number. Defaults to none.} 30 | 31 | \item{page.number.x}{Distance the page number is pushed away from the text 32 | along the x-axis.} 33 | 34 | \item{page.number.y}{Distance the page number is pushed away from the text 35 | along the y-axis.} 36 | } 37 | \value{ 38 | A ggplot object with the given visualization. 39 | } 40 | \description{ 41 | Creates a visualization from the ggpage_build output 42 | } 43 | \examples{ 44 | \donttest{ 45 | library(dplyr) 46 | library(stringr) 47 | library(ggplot2) 48 | library(tidytext) 49 | library(ggpage) 50 | # build and plot 51 | ## data.frame with full lines 52 | ggpage_build(tinderbox) \%>\% 53 | ggpage_plot() 54 | ## vector with full lines 55 | ggpage_build(book = tinderbox \%>\% 56 | pull(text)) \%>\% 57 | ggpage_plot() 58 | ## data.frame with single words 59 | ggpage_build(tinderbox) \%>\% 60 | unnest_tokens(text, word) \%>\% 61 | ggpage_plot() 62 | ## vector with single words 63 | ggpage_build(tinderbox \%>\% 64 | unnest_tokens(text, text) \%>\% 65 | pull(text)) \%>\% 66 | ggpage_plot() 67 | 68 | # nrow and ncol 69 | ggpage_build(tinderbox, nrow = 2) \%>\% 70 | ggpage_plot() 71 | ggpage_build(tinderbox, ncol = 2) \%>\% 72 | ggpage_plot() 73 | 74 | # Include analysis within 75 | ggpage_build(tinderbox) \%>\% 76 | mutate(word_length = str_length(word)) \%>\% 77 | ggpage_plot(aes(fill = word_length)) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /man/ggpage_quick.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ggpage_quick.R 3 | \name{ggpage_quick} 4 | \alias{ggpage_quick} 5 | \title{Creates a quick visualization of the page layout} 6 | \usage{ 7 | ggpage_quick(book, lpp = 25, character_height = 3, 8 | vertical_space = 1, x_space_pages = 10, y_space_pages = 10, 9 | nrow = NULL, ncol = NULL, bycol = TRUE) 10 | } 11 | \arguments{ 12 | \item{book}{Character or data.frame. Can either have each element be a 13 | separate line or having each element being separate words.} 14 | 15 | \item{lpp}{Numeric. Lines Per Page. Number of lines allocated for each page.} 16 | 17 | \item{character_height}{Numeric. Relative size of the height of each letter 18 | compared to its width.} 19 | 20 | \item{vertical_space}{Numeric. Distance between each lines vertically.} 21 | 22 | \item{x_space_pages}{Numeric. Distance between pages along the x-axis.} 23 | 24 | \item{y_space_pages}{Numeric. Distance between pages along the y-axis.} 25 | 26 | \item{nrow}{Numeric. Number of rows of pages, if omitted defaults to square 27 | layout.} 28 | 29 | \item{ncol}{Numeric. Number of columns of pages, if omitted defaults to 30 | square layout.} 31 | 32 | \item{bycol}{Logical. If TRUE (the default) the matrix is filled by 33 | columns, otherwise the matrix is filled by rows.} 34 | } 35 | \value{ 36 | A ggplot object with the given visualization. 37 | } 38 | \description{ 39 | Creates a quick visualization of the page layout 40 | } 41 | \examples{ 42 | \donttest{ 43 | library(dplyr) 44 | library(stringr) 45 | library(ggplot2) 46 | library(tidytext) 47 | library(ggpage) 48 | # quick 49 | ## data.frame with full lines 50 | ggpage_quick(tinderbox) 51 | ## vector with full lines 52 | ggpage_quick(tinderbox \%>\% 53 | pull(text)) 54 | ## data.frame with single words 55 | ggpage_quick(tinderbox \%>\% 56 | unnest_tokens(text, text)) 57 | ## vector with single words 58 | ggpage_quick(tinderbox \%>\% 59 | unnest_tokens(text, text) \%>\% 60 | pull(text)) 61 | 62 | # nrow and ncol 63 | ggpage_quick(tinderbox, nrow = 2) 64 | ggpage_quick(tinderbox, ncol = 2) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /man/line_align.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{line_align} 4 | \alias{line_align} 5 | \title{Adjust lines} 6 | \usage{ 7 | line_align(line, max_length, type) 8 | } 9 | \arguments{ 10 | \item{line}{data.frame} 11 | 12 | \item{max_length}{numerical. number of letters allowed on a line.} 13 | 14 | \item{type}{Type of line alignment. Must be one of "left", "right" or "both".} 15 | } 16 | \value{ 17 | data.frame 18 | } 19 | \description{ 20 | Adjust lines 21 | } 22 | -------------------------------------------------------------------------------- /man/nest_paragraphs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nest_paragraphs.R 3 | \name{nest_paragraphs} 4 | \alias{nest_paragraphs} 5 | \title{converts paragraph tokens into line tokens} 6 | \usage{ 7 | nest_paragraphs(data, input, ...) 8 | } 9 | \arguments{ 10 | \item{data}{data.frame. With one paragraph per row.} 11 | 12 | \item{input}{column that gets split as string or symbol.} 13 | 14 | \item{...}{Extra arguments passed to str_wrap.} 15 | } 16 | \value{ 17 | data.frame. 18 | } 19 | \description{ 20 | extents the str_wrap() function from the stringr package to work with longer 21 | strings. 22 | } 23 | -------------------------------------------------------------------------------- /man/page_liner.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{page_liner} 4 | \alias{page_liner} 5 | \title{Add line number within pages} 6 | \usage{ 7 | page_liner(data) 8 | } 9 | \arguments{ 10 | \item{data}{data.frame} 11 | } 12 | \value{ 13 | data.frame 14 | } 15 | \description{ 16 | Add line number within pages 17 | } 18 | -------------------------------------------------------------------------------- /man/paper_shape.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{paper_shape} 4 | \alias{paper_shape} 5 | \title{Identify the edges of the paper of each page} 6 | \usage{ 7 | paper_shape(data) 8 | } 9 | \arguments{ 10 | \item{data}{data.frame created by ggpage_build.} 11 | } 12 | \value{ 13 | data.frame, 14 | } 15 | \description{ 16 | Identify the edges of the paper of each page 17 | } 18 | \examples{ 19 | paper_shape(ggpage_build(tinderbox)) 20 | } 21 | -------------------------------------------------------------------------------- /man/para_index.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{para_index} 4 | \alias{para_index} 5 | \title{paragraph split} 6 | \usage{ 7 | para_index(n, FUN, ...) 8 | } 9 | \arguments{ 10 | \item{n}{Numeric. Numbers of words.} 11 | 12 | \item{FUN}{Numeric. how many words to split whole string by.} 13 | 14 | \item{...}{Extra arguments.} 15 | } 16 | \value{ 17 | Numeric. paragraph indicator. 18 | } 19 | \description{ 20 | Converts a word vector into a line vector with variable paragraph lengths. 21 | } 22 | \details{ 23 | FUN most be a function that takes in a number n and returns a vector of 24 | natural numbers. 25 | } 26 | -------------------------------------------------------------------------------- /man/pipe.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-pipe.R 3 | \name{\%>\%} 4 | \alias{\%>\%} 5 | \title{Pipe operator} 6 | \usage{ 7 | lhs \%>\% rhs 8 | } 9 | \description{ 10 | See \code{magrittr::\link[magrittr]{\%>\%}} for details. 11 | } 12 | \keyword{internal} 13 | -------------------------------------------------------------------------------- /man/tinderbox.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{tinderbox} 5 | \alias{tinderbox} 6 | \title{The tinder-box by H.C. Andersen} 7 | \format{A data frame with 211 rows and 2 variables: 8 | \describe{ 9 | \item{text}{character string up to 80 characters each} 10 | \item{book}{name of the fairy tale} 11 | ... 12 | }} 13 | \usage{ 14 | tinderbox 15 | } 16 | \description{ 17 | A tidy data.frame containing the entire story of The tinder-box by H.C. 18 | Andersen with two columns: \code{text} which contains the text of the 19 | fairy tale divided into elements of up to about 80 characters each and 20 | \code{book} giving the name of the fairy tale in question. 21 | } 22 | \keyword{datasets} 23 | -------------------------------------------------------------------------------- /man/tinderbox_paragraph.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{tinderbox_paragraph} 5 | \alias{tinderbox_paragraph} 6 | \title{The tinder-box by H.C. Andersen} 7 | \format{A data frame with 11 rows and 1 variables: 8 | \describe{ 9 | \item{text}{character string up to 80 characters each} 10 | ... 11 | }} 12 | \usage{ 13 | tinderbox_paragraph 14 | } 15 | \description{ 16 | A tidy data.frame containing the entire story of The tinder-box by H.C. 17 | Andersen with two columns: \code{text} which contains the text of the 18 | fairy tale divided into paragraphs. 19 | } 20 | \keyword{datasets} 21 | -------------------------------------------------------------------------------- /man/word_to_line.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{word_to_line} 4 | \alias{word_to_line} 5 | \title{Internal function for converting words to lines} 6 | \usage{ 7 | word_to_line(words, wot_number = 1000) 8 | } 9 | \arguments{ 10 | \item{words}{data.frame. Where each row is a separate word words with the 11 | column name text.} 12 | 13 | \item{wot_number}{Numeric. how many words to split whole string by.} 14 | } 15 | \value{ 16 | Character. have each element be a separate line. 17 | } 18 | \description{ 19 | extents the str_wrap() function from the stringr package to work with longer 20 | strings. 21 | } 22 | -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmilHvitfeldt/ggpage/83821d9dc1fa3639c6a94d4f5e3c9134697060fc/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(ggpage) 3 | 4 | test_check("ggpage") 5 | -------------------------------------------------------------------------------- /tests/testthat/test-break_help.R: -------------------------------------------------------------------------------- 1 | context("test-break_help.R") 2 | 3 | test_that("break_help returns a integer vector.", { 4 | expect_equal(is.numeric(break_help(c(1, 2, 3))), TRUE) 5 | expect_equal(is.list(break_help(c(1, 2, 3))), FALSE) 6 | }) 7 | 8 | test_that("break_help returns the right length.", { 9 | a <- 1 10 | b <- 1:2 11 | c <- 1:100 12 | 13 | expect_equal(length(break_help(a)), sum(a)) 14 | expect_equal(length(break_help(b)), sum(b)) 15 | expect_equal(length(break_help(c)), sum(c)) 16 | }) 17 | 18 | test_that("break_help returns the right values", { 19 | a <- 1 20 | b <- 1:2 21 | c <- 1:100 22 | 23 | expect_equal(as.numeric(table(break_help(a))), a) 24 | expect_equal(as.numeric(table(break_help(b))), b) 25 | expect_equal(as.numeric(table(break_help(c))), c) 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test-paper_shape.R: -------------------------------------------------------------------------------- 1 | context("test-paper_shape.R") 2 | 3 | test_that("The number of rows and cols are correct", { 4 | expect_equal(NROW(paper_shape(ggpage_build(tinderbox))), 9) 5 | expect_equal(names(paper_shape(ggpage_build(tinderbox))), 6 | c("page", "xmin", "xmax", "ymin", "ymax")) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test-para_index.R: -------------------------------------------------------------------------------- 1 | context("test-para_index.R") 2 | 3 | test_that("break_help returns a integer vector.", { 4 | n <- 100 5 | expect_equal(is.numeric(para_index(n, FUN = rpois, lambda = 10)), TRUE) 6 | expect_equal(is.list(para_index(n, FUN = rpois, lambda = 10)), FALSE) 7 | }) 8 | 9 | test_that("Returns output of correct length.", { 10 | n <- 100 11 | expect_equal(sum(para_index(n, FUN = rpois, lambda = 10)), n) 12 | }) 13 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /vignettes/different-features.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ggpage features" 3 | author: "Emil Hvitfeldt" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{ggpage features} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r setup, include = FALSE} 13 | knitr::opts_chunk$set( 14 | collapse = TRUE, 15 | comment = "#>" 16 | ) 17 | ``` 18 | 19 | ## Variable paragraph length 20 | 21 | The `ggpage` package allows for variable length of paragraphs if the text doesn't hold information regarding paragraphs. This is done by supplying the `variable.paragraph.length` argument in `ggpage_build` with a function that generate random natural numbers. Such as the `rpois` function. 22 | 23 | ```{r, message=FALSE} 24 | library(magrittr) 25 | library(dplyr) 26 | library(ggpage) 27 | 28 | 29 | book <- tinderbox %>% 30 | tidytext::unnest_tokens(text, text) 31 | 32 | ggpage_build(book, para.fun = rpois, lambda = 75) %>% 33 | ggpage_plot() 34 | ggpage_build(book, para.fun = rpois, lambda = 75) %>% 35 | ggpage_plot() 36 | ggpage_build(book, para.fun = rpois, lambda = 500) %>% 37 | ggpage_plot() 38 | ggpage_build(book, para.fun = rpois, lambda = 500) %>% 39 | ggpage_plot() 40 | ``` 41 | 42 | ## Show paper 43 | 44 | With the newest update `ggpage` allows you to draw a rectangle around each "page". 45 | 46 | ```{r} 47 | ggpage_build(tinderbox) %>% 48 | ggpage_plot(paper.show = TRUE) 49 | ``` 50 | 51 | It allows you use specify a color both as a constant, 52 | 53 | ```{r} 54 | ggpage_build(tinderbox) %>% 55 | ggpage_plot(paper.show = TRUE, paper.color = "pink") 56 | ``` 57 | 58 | or by a string of colors. In this case a faded rainbow. 59 | 60 | ```{r} 61 | ggpage_build(tinderbox) %>% 62 | ggpage_plot(paper.show = TRUE, paper.color = rainbow(9), paper.alpha = 0.3) 63 | ``` 64 | 65 | ## Show page number 66 | 67 | It can be hard to see the order of the pages in the standard vizualization. However it is possible to add a page number in the sides or corners of each page. 68 | 69 | ```{r} 70 | directions <- c("top", "top-right", "right", "bottom-right", "bottom", 71 | "bottom-left", "left", "top-left") 72 | ggpage_build(tinderbox) %>% 73 | ggpage_plot(page.number = directions[1]) 74 | ggpage_build(tinderbox) %>% 75 | ggpage_plot(page.number = directions[2]) 76 | ggpage_build(tinderbox) %>% 77 | ggpage_plot(page.number = directions[3]) 78 | ggpage_build(tinderbox) %>% 79 | ggpage_plot(page.number = directions[4]) 80 | ggpage_build(tinderbox) %>% 81 | ggpage_plot(page.number = directions[5]) 82 | ggpage_build(tinderbox) %>% 83 | ggpage_plot(page.number = directions[6]) 84 | ggpage_build(tinderbox) %>% 85 | ggpage_plot(page.number = directions[7]) 86 | ggpage_build(tinderbox) %>% 87 | ggpage_plot(page.number = directions[8]) 88 | 89 | ``` 90 | 91 | ## Variable page length 92 | 93 | The package also support a variable page length. This can be helpful when a collection of smaller texts are considered in the same vizualisation such as tweets. 94 | 95 | ```{r} 96 | tinderbox %>% 97 | mutate(short = ceiling(seq_len(nrow(tinderbox)) / 10)) %>% 98 | ggpage_build(page.col = "short", lpp = 10) %>% 99 | ggpage_plot() 100 | ``` 101 | 102 | ## Centering 103 | 104 | `ggpage` now supports left, right and both-sided alignments. 105 | 106 | ```{r} 107 | ggpage_build(tinderbox, align = "right") %>% 108 | ggpage_plot() 109 | 110 | ggpage_build(tinderbox, align = "both") %>% 111 | ggpage_plot() 112 | ``` 113 | 114 | ## Paragraph to line 115 | 116 | Lastly for convience does `ggpage` include a way to transform a data.frame with paragraph tokens to a data.frame with line tokens. 117 | 118 | ```{r} 119 | nest_paragraphs(data = tinderbox_paragraph, input = text) %>% 120 | head() 121 | 122 | nest_paragraphs(tinderbox_paragraph, text, width = 40) %>% 123 | head() 124 | ``` 125 | --------------------------------------------------------------------------------