{"id":13711987,"url":"https://github.com/const-ae/ggsignif","last_synced_at":"2025-05-15T07:05:21.465Z","repository":{"id":19465826,"uuid":"87104174","full_name":"const-ae/ggsignif","owner":"const-ae","description":"Easily add significance brackets to your ggplots","archived":false,"fork":false,"pushed_at":"2024-08-11T05:11:21.000Z","size":15168,"stargazers_count":605,"open_issues_count":29,"forks_count":45,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-03T03:11:09.951Z","etag":null,"topics":["asterisk","ggplot-extension","ggplot2","rstats","significance-stars"],"latest_commit_sha":null,"homepage":"https://const-ae.github.io/ggsignif/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/const-ae.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null}},"created_at":"2017-04-03T17:56:42.000Z","updated_at":"2025-05-03T00:38:20.000Z","dependencies_parsed_at":"2023-01-13T20:23:05.143Z","dependency_job_id":"8d9c6e3b-5888-414f-b59d-244ba3073563","html_url":"https://github.com/const-ae/ggsignif","commit_stats":{"total_commits":166,"total_committers":12,"mean_commits":"13.833333333333334","dds":"0.45783132530120485","last_synced_commit":"080e11924bec22de19057ae64231353bdd033cd9"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2Fggsignif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2Fggsignif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2Fggsignif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2Fggsignif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/const-ae","download_url":"https://codeload.github.com/const-ae/ggsignif/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254050475,"owners_count":22006300,"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":["asterisk","ggplot-extension","ggplot2","rstats","significance-stars"],"created_at":"2024-08-02T23:01:13.717Z","updated_at":"2025-05-15T07:05:16.435Z","avatar_url":"https://github.com/const-ae.png","language":"R","funding_links":[],"categories":["Plot layers","R","Table of Contents"],"sub_categories":["Visualization"],"readme":"---\noutput: github_document\n---\n\n# ggsignif: Significance Brackets for 'ggplot2' \u003ca href='https://github.com/const-ae/ggsignif'\u003e\u003cimg src='man/figures/logo.svg' align=\"right\" height=\"209\" /\u003e\u003c/a\u003e\n\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/ggsignif)](https://cran.r-project.org/package=ggsignif)\n[![R build status](https://github.com/const-ae/ggsignif/workflows/R-CMD-check/badge.svg)](https://github.com/const-ae/ggsignif/actions)\n[![Total downloads badge](https://cranlogs.r-pkg.org/badges/grand-total/ggsignif?color=blue)](https://CRAN.R-project.org/package=ggsignif)\n[![Codecov test coverage](https://codecov.io/gh/const-ae/ggsignif/branch/main/graph/badge.svg)](https://app.codecov.io/gh/const-ae/ggsignif?branch=main)\n[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  dpi = 300,\n  out.width = \"100%\",\n  fig.path = \"man/figures/README-\",\n  message = FALSE,\n  warning = FALSE\n)\n```\n\n## Introduction\n\nThis package provides an easy way to indicate if two groups are significantly\ndifferent. Commonly this is shown by a bar on top connecting the groups of\ninterest which itself is annotated with the level of significance (NS, \\*, \\*\\*,\n\\*\\*\\*). The package provides a single layer (`geom_signif`) that takes the\ngroups for comparison and the test (t.test, wilcox etc.) and adds the annotation\nto the plot.\n\n## Citation\n\nIf you wish to cite this package in a publication, you can run the following\ncommand in your R console:\n\n```{r citation}\ncitation(\"ggsignif\")\n```\n\n## Example\n\nYou can first install this package from `CRAN`:\n\n```{r eval=FALSE}\ninstall.packages(\"ggsignif\")\n```\n\nOr get the latest development version:\n\n```{r eval=FALSE}\ninstall.packages(\"remotes\")\nremotes::install_github(\"const-ae/ggsignif\")\n```\n\nPlot significance\n\n```{r simpe_comparison}\nlibrary(ggplot2)\nlibrary(ggsignif)\n\np1 \u003c- ggplot(mpg, aes(class, hwy)) +\n  geom_boxplot() +\n  geom_signif(\n    comparisons = list(c(\"compact\", \"midsize\"), c(\"minivan\", \"suv\")),\n    map_signif_level = TRUE, textsize = 6\n  ) +\n  ylim(NA, 48)\np1\n```\n\nControl the direction (either `x` or `y`) via `orientation` \n\n```{r orientation_argument}\np2 \u003c- ggplot(\n  data = mpg,\n  mapping = aes(\n    x = hwy,\n    y = class\n  )\n) +\n  geom_boxplot(\n    orientation = \"y\"\n  ) +\n  geom_signif(\n    comparisons = list(\n      c(\"compact\", \"midsize\"),\n      c(\"minivan\", \"suv\")\n    ),\n    map_signif_level = TRUE,\n    textsize = 6,\n    margin_top = 0.08,\n    step_increase = 0.05,\n    tip_length = 0.01,\n    orientation = \"y\"\n  )\np2\n```\n\nCompatible with coord_flip\n\n```{r coord_flip}\np1 + coord_flip()\n``` \n\nSetting the precise location\n\nThis is important if you use `position=\"dodge\"`, because in that case I cannot\ncalculate the correct position of the bars automatically.\n\n```{r dodge_comparison}\n# Calculate annotation\nanno \u003c- t.test(\n  iris[iris$Petal.Width \u003e 1 \u0026 iris$Species == \"versicolor\", \"Sepal.Width\"],\n  iris[iris$Species == \"virginica\", \"Sepal.Width\"]\n)$p.value\n\n# Make plot with custom x and y position of the bracket\nggplot(iris, aes(x = Species, y = Sepal.Width, fill = Petal.Width \u003e 1)) +\n  geom_boxplot(position = \"dodge\") +\n  geom_signif(\n    annotation = formatC(anno, digits = 1),\n    y_position = 4.05, xmin = 2.2, xmax = 3,\n    tip_length = c(0.2, 0.04)\n  )\n```\n\n`ggsignif` is compatible with facetting (`facet_wrap` or `facet_grid`). The significance label is calculated for each facet where the axis labels listed in `comparisons` occur. Note that `ggsignif` fails to calculate the significance if the data is grouped globally (e.g., by setting `color`, `fill`, or `group` in `ggplot(aes(...))`). It is fine to group the data per geom (e.g., set the fill within `geom_boxplot(aes(fill = ...)))`.\n\n```{r faceted_simple}\nggplot(diamonds, aes(x = cut, y = carat)) +\n  geom_boxplot(aes(fill = color)) +\n  geom_signif(comparisons = list(\n    c(\"Fair\", \"Good\"),\n    c(\"Very Good\", \"Ideal\")\n  )) +\n  facet_wrap(~color) +\n  ylim(NA, 6.3)\n```\n\n\n\n## Advanced Example\n\nSometimes one needs to have a very fine tuned ability to set the location of the\nthe significance bars in combination with `facet_wrap` or `facet_grid`. In those\ncases it you can set the flag `manual=TRUE` and provide the annotations as a\ndata.frame:\n\n```{r faceted_comparison}\nannotation_df \u003c- data.frame(\n  color = c(\"E\", \"H\"),\n  start = c(\"Good\", \"Fair\"),\n  end = c(\"Very Good\", \"Good\"),\n  y = c(3.6, 4.7),\n  label = c(\"Comp. 1\", \"Comp. 2\")\n)\n\nannotation_df\n\nggplot(diamonds, aes(x = cut, y = carat)) +\n  geom_boxplot() +\n  geom_signif(\n    data = annotation_df,\n    aes(xmin = start, xmax = end, annotations = label, y_position = y),\n    textsize = 3, vjust = -0.2,\n    manual = TRUE\n  ) +\n  facet_wrap(~color) +\n  ylim(NA, 5.3)\n```\n\nYou can ignore the warning about the missing aesthetics.\n\nFor further details, see:\n\u003chttps://const-ae.github.io/ggsignif/articles/intro.html\u003e\n\n## Maintenance\n\nThis package is provided as is and we currently don't have any plans and the\ncapacity to add any new features to it. If there is nonetheless a feature which\nyou would like to see in the package, you are always welcome to submit pull\nrequest, which we will try to address as soon as possible.\n\n## Code of Conduct\n  \nPlease note that the `ggsignif` project is released with a [Contributor Code of Conduct](https://const-ae.github.io/ggsignif/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconst-ae%2Fggsignif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconst-ae%2Fggsignif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconst-ae%2Fggsignif/lists"}