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

ggpivot

The goal of ggpivot is to make tables w ggplot2.

Specify x and y categorical variables; let ggplot2 count number of observations or calculate proportions.

Installation

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("EvaMaeRey/ggpivot")
library(tidyverse)
library(magrittr)

a geom that counts categories and prints the count

geom_text_twowaycount_script <- readLines("./R/geom_text_twowaycount.R")

library(ggplot2)
ggplot(data = mtcars) +
aes(x = cyl, y = gear) +
geom_text_twowaycount()

a geom that is a tile and fills (color) according to count

geom_tile_twowaycount_script <- readLines("./R/geom_tile_twowaycount.R")

library(ggplot2)
ggplot(data = mtcars) +
aes(x = cyl, y = gear) +
geom_tile_twowaycount() +
geom_text_twowaycount(color = "oldlace")

a geom that is a tile and fills (color) according to proportion within column (x)

geom_tile_prop_within_x_script <- readLines("./R/geom_tile_prop_within_x.R")

geom_text_prop_within_x_script <- readLines("./R/geom_text_prop_within_x.R")

library(ggplot2)
ggplot(data = mtcars) +
aes(x = cyl, y = gear) +
geom_tile_prop_within_x(width = .8) +
geom_text_prop_within_x(color = "oldlace") +
  aes(fill = 1)


EvaMaeRey/ggpivot documentation built on April 5, 2022, 12:02 p.m.