knitr::opts_chunk$set(
  # these options tend to vary from one Rmd to another
  echo      = TRUE,
  fig.path  = "man/figures/README-",

  # these options tend to remain constant
  collapse  = TRUE,
  comment   = "#>",
  message   = FALSE,
  warning   = FALSE,
  fig.width = 7,
  fig.asp   = 1 / 1.6,
  out.width = "70%",
  fig.align = "center",
  error     = TRUE,
  purl      = FALSE

  # http://r-pkgs.had.co.nz/vignettes.html: error = TRUE captures errors in
  # the block and shows them inline. This is useful for demonstrating what
  # happens if code throws an error. If you use error = TRUE, set
  # purl = FALSE. Vignettes are accompanied by files containing all the
  # code from the vignette. purl = FALSE prevents the code from being
  # inserted into that file
)

knitr::knit_hooks$set(inline = function(x) {
  if (!is.numeric(x)) {
    x
  } else if (x >= 10000) {
    prettyNum(round(x, 2), big.mark = ",")
  } else {
    prettyNum(round(x, 2))
  }
})

options(tibble.print_min = 8L, tibble.print_max = 8L)

graphclassmate

Overview

An R package with companion materials for a course in data visualization.

The package provides data sets structured for a variety of graph types plus a ggplot2 theme.

Installation

Not yet available from CRAN. The development version can be installed from GitHub.

install.packages("devtools")
devtools::install_github("graphdr/graphclassmate")

Usage

rcb() accesses the rcb_colors data frame and returns a hex color code. Thus rcb(rcb_name) can be substituted for any color argument. For example

library("ggplot2")
library("graphclassmate")
ggplot(data = mpg, aes(x = displ, y = hwy)) +
  geom_point(color = rcb("dark_BG")) +
  theme_graphclass()

theme_graphclass() is a variation on ggplot2::theme_minimal() with all panel and axis text set to the same font face and size and all grid lines and panel borders set to the same line size and color. Optional arguments allow one to edit the common font size, line size, and line color.

Data in the package:

d <- data(package = "graphclassmate")[["results"]]
knitr::kable(d[ , c("Item", "Title")])

The data sets are for illustrating different graph designs, e.g., box plots, multiways, scatterplots, dot plots, conditioning plots, scatterplot matrices, and parallel coordinate plots. Including these data in the package gives students quick access to data for tutorials and exercises.

Meta



graphdr/graphclassmate documentation built on May 27, 2021, 4:41 a.m.