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
.
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")
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.
We recommened using dummify()
from the DataExplorer
package. It
takes three arguments:
data : Input data
maxcat : maximum categories allowed for each discrete feature. Default is 50.
select : names of selected features to be dummified. Default is
NULL
.
returns a dummified dataset (discrete features only) preserving original features. Column order might be different.
Note:
Continuous features will be ignored if added in select
.
select
features will be ignored if categories exceed maxcat
.
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
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>
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.