knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
library(palmerpenguins)
data(penguins)

tools42

The goal of tools42 is to make life easier for folks at ideas42 who are doing analytical work. While this is a work in progress, our goal is to include features like:

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("ideas42/tools42")

Plots

This is a basic example which shows you how to solve a common problem: plotting your data. Let's start with a scatterplot and histogram.

library(tools42)

## Plotting a histogram of penguin bill length

viz_hist(penguins, bill_length_mm) +
  theme_42()
## Simple scatterplot

viz_scatter(penguins, bill_length_mm, flipper_length_mm) +
  theme_42()

Themes

As you saw in the last section, we also have some themes. These are designed to make your plots looks nicer, and so far there's two of them. The first, theme_42, is a simple, clean, theme that minimizes clutter.

library(ggplot2)

viz_scatter(penguins, bill_length_mm, flipper_length_mm) + 
  labs(title = "This is a sample plot",
       subtitle = "And this is the subtitle") +
  theme_42()

We also have a brighter, warmer theme. To use it, just add theme_42_bright to your call. This can be used with the helper functions viz_* as well as with regular ggplot calls:

ggplot(penguins, aes(bill_length_mm, flipper_length_mm)) + 
  geom_point() +
  labs(title = "This is a sample plot",
       subtitle = "And this is the subtitle") +
  theme_42_bright()

Color schemes

Lastly, we've created some color schemes for you. There's two palettes: i42, and i42_bright. To visualize them, just use the palette_42 function.

palette_42("i42_bright")

Here's what it looks like when we combine it with a previous plot.

ggplot(penguins, aes(bill_length_mm, flipper_length_mm, color = species)) + 
  geom_point() +
  labs(title = "This is a sample plot",
       subtitle = "And this is the subtitle") +
  theme_42_bright() +
  scale_color_manual(values = palette_42("i42_bright"))


ideas42/tools42 documentation built on Jan. 31, 2021, 7:23 p.m.