Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: ozancanozdemir
  • License: other
  • Language: R
  • Default Branch: main
  • Size: 16.6 KB
Statistics
  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • Open Issues: 8
  • Releases: 0
Created about 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme

README.md

ggsegmentedtotalbar R package

It is the first ggplot2-based R package to create the segmented total bar plot in R.

Installation

You can install the development version of ggsegmentedtotalbar like so:

r devtools::install_github("https://github.com/ozancanozdemir/ggsegmentedtotalbar")

It is on its way to CRAN!

Details

Kevin Flerlage, who is a data visualization specialist, suggested a great alternative to a stacked bar plot on his blog. He called this new alternative a "segmented total bar plot". This R package ggsegmentedtotalbar implements this idea. The package is built on top of the ggplot2 package, which is a popular data visualisation package in R. The ggsegmentedtotalbar function creates a segmented total bar plot with custom annotations (boxes) added for each group. The height of each box is determined by the Total value associated with each group.

The core thing behind the usage of ggsegmentedtotalbar is to create a data frame with the following columns:

  • group: A string representing the name of the grouping variable.
  • segment: A string representing the name of the segmenting variable.
  • value: A string representing the name of the value variable (used for the height of bars).
  • total: A string representing the name of the total variable (used for determining the box height for each group).

The good thing is that your data frame does not have to have the same column names. However, you need to specify the names of the columns in the data frame when calling the ggsegmentedtotalbar function correctly.

The function ggsegmentedtotalbar takes a data frame and the names of the columns as arguments. It creates a bar plot based on grouped data with annotations (boxes) added for each group. The height of each box is determined by the Total value associated with each group.

Usage

``` r

Example data frame

df_ex <- data.frame( group = c("A", "A","A","B", "B","B","C","C","C","D","D","D"), segment = c("X","Y","Z", "X","Y","Z", "X","Y","Z","X","Y","Z"), value = c(10, 20, 30, 40,50,60, 70,80,90, 100, 110, 120), total = c(60,60,60, 150,150,150, 240,240,240, 360,360,360) ) ```

```r

Create the segmented total bar plot

p <- ggsegmentedtotalbar(df_ex, "group", "segment", "value", "total")

Print the plot

print(p) ```

image

The function also provides three parameters that you can use to customize the plot:

  • alpha: A numeric value (between 0 and 1) controlling the transparency of the background boxes. Default is 0.3.
  • color: A string specifying the color of the background boxes. Default is "lightgrey".
  • label: Logical. If TRUE, adds labels showing total values above the boxes and value labels on each segment. Default is FALSE.

```r

Create the segmented total bar plot with labels

p <- ggsegmentedtotalbar(dfex, "group", "segment", "value", "total", label = TRUE, labelsize = 4, label_color = "black")

Print the plot

print(p) ```

image

```r

Create the segmented total bar plot with labels and different total box.

p <- ggsegmentedtotalbar(dfex, "group", "segment", "value", "total", label = TRUE, labelsize = 4, label_color = "black", alpha = 0.2, color = "steelblue")

Print the plot

print(p) ```

image

Apart from these parameters, you can also customize your plot by utilizing ggplot2 related functions. Here is another example.

```r

Create the segmented total bar plot with labels and different total box.

p <- ggsegmentedtotalbar(dfex, "group", "segment", "value", "total", label = TRUE, labelsize = 4, labelcolor = "black", alpha = 0.2, color = "steelblue") + ggplot2::labs(title = "Segmented Total Bar Plot with Custom Annotations", x = "Group", y= "Value") + ggplot2::themetest() + ggplot2::theme( plot.title = ggplot2::elementtext(hjust = 0.5), axis.text.x = ggplot2::elementtext(face= "bold", hjust = 1), axis.text.y = ggplot2::elementtext(face= "bold", hjust = 1), legend.position = "top", legend.title = ggplot2::elementblank(), )

Print the plot

print(p) ```

image

Owner

  • Name: Ozancan Özdemir
  • Login: ozancanozdemir
  • Kind: user
  • Company: Middle East Technical University

-Research and Teaching Assistant. -A statistician who is interested in time series and machine learning.

GitHub Events

Total
  • Issues event: 2
  • Watch event: 6
  • Issue comment event: 1
  • Push event: 6
  • Pull request event: 5
  • Fork event: 1
  • Create event: 2
Last Year
  • Issues event: 2
  • Watch event: 6
  • Issue comment event: 1
  • Push event: 6
  • Pull request event: 5
  • Fork event: 1
  • Create event: 2

Packages

  • Total packages: 1
  • Total downloads:
    • cran 194 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
cran.r-project.org: ggsegmentedtotalbar

Create a Segmented Total Bar Plot with Custom Annotations and Labels

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 194 Last month
Rankings
Dependent packages count: 26.7%
Dependent repos count: 32.9%
Average: 48.8%
Downloads: 86.8%
Maintainers (1)
Last synced: 10 months ago