README.md

ggradialbar

Build
Status R-CMD-check codecov

The goal of ggradialbar is to provide ggplot2 geom extensions for the radial barchart visualization. This package is based on Uli Niemann’s code, with new geom layer implementations using ‘ggproto’ system of object oriented programming used in ggplot2.

Installation

You can install the released version of ggradialbar from CRAN with:

install.packages("ggradialbar")

Or the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("Ashish-Soni08/ggradialbar")

Data preprocessing required for using ggradialbar

Note: This is just a friendly reminder about the data transformations needed, before you plot the data using the visualization provided by ggradialbar. The first two transformations already take place when you perform Clustering.

1. Encoding multi-valued categorical features (categorical data e.g.gender-male, female).

We recommened using dummify() from the DataExplorer package. It takes three arguments:

returns a dummified dataset (discrete features only) preserving original features. Column order might be different.

Note:

You can find an example below.

# install.packages("librarian")
librarian::shelf(tidyverse, DataExplorer , quiet = TRUE)

dummified_dataset <- dummify(iris, maxcat = 5, select = "Species")

head(dummified_dataset)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species_setosa
#> 1          5.1         3.5          1.4         0.2              1
#> 2          4.9         3.0          1.4         0.2              1
#> 3          4.7         3.2          1.3         0.2              1
#> 4          4.6         3.1          1.5         0.2              1
#> 5          5.0         3.6          1.4         0.2              1
#> 6          5.4         3.9          1.7         0.4              1
#>   Species_versicolor Species_virginica
#> 1                  0                 0
#> 2                  0                 0
#> 3                  0                 0
#> 4                  0                 0
#> 5                  0                 0
#> 6                  0                 0
2. Scale data - The range of values of features varies, so we normalize variables using z-score normalization.
scaled_dataset <- scale(dummified_dataset, center = TRUE, scale = TRUE)

scaled_dataset <-  as_tibble(scaled_dataset)

head(scaled_dataset)
#> # A tibble: 6 x 7
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species_setosa
#>          <dbl>       <dbl>        <dbl>       <dbl>          <dbl>
#> 1       -0.898      1.02          -1.34       -1.31           1.41
#> 2       -1.14      -0.132         -1.34       -1.31           1.41
#> 3       -1.38       0.327         -1.39       -1.31           1.41
#> 4       -1.50       0.0979        -1.28       -1.31           1.41
#> 5       -1.02       1.25          -1.34       -1.31           1.41
#> 6       -0.535      1.93          -1.17       -1.05           1.41
#> # ... with 2 more variables: Species_versicolor <dbl>, Species_virginica <dbl>
3. Data in Long format - ggplot2 functions like data in the ‘long’ format , so convert data from wide to long form.
data <- pivot_longer(data = scaled_dataset, names_to = "feature", values_to = "value", cols = everything())

head(data)
#> # A tibble: 6 x 2
#>   feature             value
#>   <chr>               <dbl>
#> 1 Sepal.Length       -0.898
#> 2 Sepal.Width         1.02 
#> 3 Petal.Length       -1.34 
#> 4 Petal.Width        -1.31 
#> 5 Species_setosa      1.41 
#> 6 Species_versicolor -0.705

Use ‘ggradialbar’



Ashish-Soni08/ggradialbar documentation built on April 15, 2021, 4:11 a.m.