{"id":13710937,"url":"https://dkibalnikov.github.io/donutsk/","last_synced_at":"2025-05-06T20:31:22.370Z","repository":{"id":230122701,"uuid":"776755394","full_name":"dkibalnikov/donutsk","owner":"dkibalnikov","description":"Creating donut charts without a hassle ","archived":false,"fork":false,"pushed_at":"2024-04-24T06:34:49.000Z","size":11622,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T09:37:09.566Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://dkibalnikov.github.io/donutsk/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dkibalnikov.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-24T12:02:02.000Z","updated_at":"2024-05-07T18:34:10.000Z","dependencies_parsed_at":"2024-04-21T10:38:00.651Z","dependency_job_id":"00b51e05-419f-4533-9a85-561e38c602e1","html_url":"https://github.com/dkibalnikov/donutsk","commit_stats":null,"previous_names":["dkibalnikov/donutsk"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkibalnikov%2Fdonutsk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkibalnikov%2Fdonutsk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkibalnikov%2Fdonutsk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkibalnikov%2Fdonutsk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkibalnikov","download_url":"https://codeload.github.com/dkibalnikov/donutsk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252764277,"owners_count":21800665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:01:02.436Z","updated_at":"2025-05-06T20:31:21.867Z","avatar_url":"https://github.com/dkibalnikov.png","language":"R","funding_links":[],"categories":["Plot layers"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# donutsk \u003ca href=\"https://dkibalnikov.github.io/donutsk/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"139\" alt=\"donutsk website\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![R-CMD-check](https://github.com/dkibalnikov/donutsk/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dkibalnikov/donutsk/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/dkibalnikov/donutsk/branch/main/graph/badge.svg)](https://app.codecov.io/gh/dkibalnikov/donutsk?branch=main)\n\u003c!-- badges: end --\u003e\n\nThe Donutsk package allows you to build donut/pie charts with ggplot2 layer by layer, exploiting the advantages of polar symmetry. The package is designed to address the limitations of pie charts, which are well-known, while also capitalizing on their ability to effectively represent hierarchical data structures. The following features are worth to be highlighted:\n\n- Create pie or donut charts while retaining ggplot2 flexibility, such as leveraging faceting and palettes, and fine-tuning appearance\n- The layout functions help to streamline displaying text and labels *geoms* without overlapping effectively leveraging space available for pie and donut charts\n- The `packing()` function arranges data to distribute small values further apart from each other\n- The set of annotation functions utilizes layout functions to effectively distribute labels within the available space \n- The label functions supports `glue::glue()` for convenient label construction like `Total: {.sum}`, where `.sum` is pre-calculated variable.\n\n## Installation\n\nYou can install the development version of donutsk from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"dkibalnikov/donutsk\")\n```\n\nCRAN installation: \n\n``` r\ninstall.packages(\"donutsk\")\n```\n\n## Example\n\nBasic example:\n\n```{r example, fig.height=11, fig.width=11}\nlibrary(donutsk)\n\n# Create an example data set\nn \u003c- 40\nset.seed(2021)\ndf \u003c- dplyr::tibble(\n lvl1 = sample(LETTERS[1:5], n, TRUE),\n lvl2 = sample(LETTERS[6:24], n, TRUE),\n value = sample(1:20, n, TRUE),\n highlight_ext = sample(c(FALSE,TRUE), n, TRUE, c(.9, .1))) |\u003e\n dplyr::mutate(highlight_int = dplyr::if_else(lvl1 == \"A\",TRUE,FALSE))\n\n# Doubled donut with advanced labeling \ndplyr::group_by(df, lvl1, lvl2, highlight_ext, highlight_int) |\u003e\n  dplyr::summarise(value = sum(value), .groups = \"drop\") |\u003e\n  # Pack values effectively \n  packing(value, lvl1) |\u003e \n  ggplot(aes(value = value, fill = lvl1)) +\n  # The donutsk visualization functions\n  geom_donut_int(aes(highlight = highlight_int), alpha=.5, r_int = .25) +\n  geom_label_int(aes(label = \"Sum {fill}:\\n{.sum} ({scales::percent(.prc)})\"),\n                 alpha = .6, col = \"white\", r=1.2) +\n  geom_donut_ext(aes(opacity = lvl2, highlight = highlight_ext)) +\n  geom_label_ext(aes(label = paste0(lvl2, \": {scales::percent(.prc_grp)}\")),\n                 show.legend = FALSE, col=\"white\", \n                 layout = tv(thinner = TRUE)) +\n  geom_pin(size=.5, linewidth=.1, show.legend = FALSE, cut = .25,\n           layout = tv(thinner = TRUE)) +\n  # Additional appearance settings\n  scale_fill_viridis_d(option = \"inferno\", begin = .1, end = .7) +\n  theme_void() + \n  theme(legend.position = \"none\")  + \n  coord_polar(theta = \"y\")\n```\n\n## Alternatives \n\nThere is a list of packages that can be considered as alternatives:\n\n- [sunburstR](https://github.com/timelyportfolio/sunburstR/): Easily create interactive d3.js sequence sunburst charts in R, originally modeled on an example from Kerry Rodden. Additionally, sunburstR provides another version using d2b from Kevin Warne.\n- [tastypie](https://github.com/PaoloDalena/tastypie/): Build pie charts with nice templates.\n- [webr](https://github.com/cardiomoon/webr): Check the `PieDonut()` function.\n- [ggpubr](https://github.com/kassambara/ggpubr/): The ‘ggpubr’ package provides easy-to-use functions for creating and customizing ‘ggplot2’-based publication-ready plots. Check `ggpubr::ggpie()` for details.\n\n## Considerations\n\nThe following list of ideas is considered as a kind of roadmap:\n\n1. Integrate round annotations with [geomtextpath](https://allancameron.github.io/geomtextpath/) under the hood.\n2. Expand the list of layouts with more sophisticated algorithms\n3. Integrate pattern aesthetics with [ggpattern](https://coolbutuseless.github.io/package/ggpattern/index.html)\n4. Calculate the precise square value for highlighted segments to adjust size \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/dkibalnikov.github.io%2Fdonutsk%2F","html_url":"https://awesome.ecosyste.ms/projects/dkibalnikov.github.io%2Fdonutsk%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/dkibalnikov.github.io%2Fdonutsk%2F/lists"}