MyNixOS website logo
Description

A Heatmap-Like Visualization Tool.

A data visualization design that provides comparison between two (Double) data sources (usually on a par with each other) on one reformed heatmap, while inheriting 'ggplot2' features.

ggDoubleHeat

R-CMD-check CRANstatus Lifecycle:stable

The ggDoubleHeat package is a ggplot2 extension that provides visualization for data from two different sources on a modified heat map. All functions from the package are named as geom_heat_*(). A regular heat map, which can be made by using geom_tile() from ggplot2, contains three dimensions (variables). geom_heat_*(), however, can express four dimensions of data on a single plot.

Installation

Please install the released version of ggDoubleHeat from CRAN with:

install.packages("ggDoubleHeat")

Alternatively, you can install the latest development version from Github with:

# install.packages("devtools")
devtools::install_github("PursuitOfDataScience/ggDoubleHeat")

Usage

For demonstration purposes, the built-in dataset pitts_tg is used to illustrate the basic usage of the package.

library(ggDoubleHeat)
library(ggplot2)
pitts_tg
## # A tibble: 270 x 6
##    msa         week week_start category          Twitter  Google
##    <chr>      <int> <date>     <chr>               <dbl>   <dbl>
##  1 Pittsburgh     1 2020-06-01 Covid              0.965  0.681  
##  2 Pittsburgh     1 2020-06-01 General Virus      0.538  0.0982 
##  3 Pittsburgh     1 2020-06-01 Masks              0.466  0.117  
##  4 Pittsburgh     1 2020-06-01 Sanitizing         0.0561 0.127  
##  5 Pittsburgh     1 2020-06-01 Social Distancing  0.294  0.0386 
##  6 Pittsburgh     1 2020-06-01 Symptoms           0.0457 0.0770 
##  7 Pittsburgh     1 2020-06-01 Tests              0.0130 0.00415
##  8 Pittsburgh     1 2020-06-01 Treatment          0.0459 0.0376 
##  9 Pittsburgh     1 2020-06-01 Working            0.295  0.160  
## 10 Pittsburgh     2 2020-06-08 Covid              1.01   0.707  
## # ... with 260 more rows

pitts_tg is a dataset that collects the 30-week period of COVID-related Google & Twitter incidence rate for 9 different categories from the Pittsburgh Metropolitan Statistical Area (MSA). For the complete information of the dataset, please type ?pitts_tg on the console.

Let’s start with geom_heat_grid():

ggplot(data = pitts_tg, aes(x = week, y = category)) +
  geom_heat_grid(outside = Google, inside = Twitter) +
  ggtitle("Pittsburgh Google & Twitter Incidence Rate (%) Comparison")

Now changing geom_heat_grid() to geom_heat_circle():

ggplot(data = pitts_tg, aes(x = week, y = category)) +
  geom_heat_circle(outside = Google, inside = Twitter) +
  ggtitle("Pittsburgh Google & Twitter Incidence Rate (%) Comparison")

Let’s use geom_heat_tri():

ggplot(data = pitts_tg, aes(x = week, y = category)) +
  geom_heat_tri(lower = Google, upper = Twitter) +
  ggtitle("Pittsburgh Google & Twitter Incidence Rate (%) Comparison")

To make things a bit more colorful, the most popular emoji for a given week in a given category from the respective Pittsburgh Twitter daily sample files is rendered on each component of the heatgrid by using ggtext. The following code is commented, as it takes few minutes to generate. If you would like to run it, just simply uncomment the code. But the generated heatgrid with emojis is attached below as an image.

# install.packages("ggtext")
# library(ggtext)
# 
# ggplot(data = pitts_tg, aes(x = week, y = category)) +
#   geom_heat_grid(outside = Google, inside = Twitter) +
#   # rendering emojis using "richtext"
#   annotate("richtext", x = rep(c(1:30), 9), y = rep(1:9, each = 30), 
#            label = pitts_emojis, label.color = NA, fill = NA, size = 0.3) +
#   ggtitle("Pittsburgh Google & Twitter Incidence Rate (%) Comparison")

image

Note: pitts_emojis is the Emoji metadata built in ggDoubleHeat. Another thing worth noting is that there are some grids not having Emoji, and the reason is that there is no Emoji Unicode in the Twitter sample file.

Metadata

Version

0.1.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows