ochathemes

knitr::opts_chunk$set(
  collapse = TRUE,
  warning = FALSE,
  message = FALSE,
  eval = FALSE,
  fig.width = 10,
  fig.path = "inst/img/",
  comment = "#> ")

hook_output <- knitr::knit_hooks$get("output")
knitr::knit_hooks$set(output = function(x, options) {
   lines <- options$output.lines
   if (is.null(lines)) {
     return(hook_output(x, options))  # pass to default hook
   }
   x <- unlist(strsplit(x, "\n"))
   more <- "..."
   if (length(lines)==1) {        # first n lines
     if (length(x) > lines) {
       # truncate the output, but add ....
       x <- c(head(x, lines), more)
     }
   } else {
     x <- c(if (abs(lines[1])>1) more else NULL,
            x[lines],
            if (length(x)>lines[abs(length(lines))]) more else NULL
           )
   }
   # paste these lines together
   x <- paste(c(x, ""), collapse = "\n")
   hook_output(x, options)
 })

knitr::opts_chunk$set(
  comment = "#>",
  echo = TRUE,
  collapse = TRUE,
  eval = FALSE,
  warning = FALSE,
  message = FALSE
)

GitLab CI Build Status Codecov Code Coverage License: MIT

ochathemes is package providing ggplot2 themes and theme components inspired by OCHA graphics stylebook.

Installation

This package is not on yet on CRAN and to install it, you will need the remotes package.

## install.packages("remotes") 
remotes::install_gitlab("dickoa/ochathemes")

Using icons from the humicons package

library(ochathemes)
library(humicons)
library(ggplot2)

ggplot(mtcars, aes(mpg, wt)) +
    geom_text(family = font_hum, label = humicons("un-vehicle"), size = 7, color = "#418FDE") +
    labs(title = "Using the UN-Vehicle icon in ggplot2", x = "", y = "") +
    theme_ocha(grid = "XY")

Meta



mmusori/ochathemes documentation built on May 29, 2019, 8:36 a.m.