{"id":13712132,"url":"https://github.com/PhDMeiwp/ggtrendline","last_synced_at":"2025-05-06T21:33:15.030Z","repository":{"id":57676091,"uuid":"481235941","full_name":"PhDMeiwp/ggtrendline","owner":"PhDMeiwp","description":"ggtrendline: An R Package for Adding Trendline and Confidence Interval to 'ggplot'.","archived":false,"fork":false,"pushed_at":"2022-05-04T11:55:38.000Z","size":102,"stargazers_count":26,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-26T22:34:40.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://CRAN.R-project.org/package=ggtrendline","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PhDMeiwp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-13T13:51:22.000Z","updated_at":"2025-02-27T05:04:30.000Z","dependencies_parsed_at":"2022-09-03T00:11:56.051Z","dependency_job_id":null,"html_url":"https://github.com/PhDMeiwp/ggtrendline","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhDMeiwp%2Fggtrendline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhDMeiwp%2Fggtrendline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhDMeiwp%2Fggtrendline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhDMeiwp%2Fggtrendline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PhDMeiwp","download_url":"https://codeload.github.com/PhDMeiwp/ggtrendline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252772333,"owners_count":21801908,"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:15.212Z","updated_at":"2025-05-06T21:33:14.759Z","avatar_url":"https://github.com/PhDMeiwp.png","language":"R","funding_links":[],"categories":["Plot layers"],"sub_categories":[],"readme":"# ggtrendline: an R package for adding trendline and confidence interval to ggplot\n\n\u003ca href=\"https://sm.ms/image/JGF8MWVbRwh2X17\" target=\"_blank\"\u003e\u003cimg src=\"https://s2.loli.net/2022/04/13/JGF8MWVbRwh2X17.png\" height=\"300\" align=\"right\"\u003e\u003c/a\u003e\n\n[![cran version](http://www.r-pkg.org/badges/version/ggtrendline)](http://cran.rstudio.com/web/packages/ggtrendline) \n[![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/grand-total/ggtrendline)](https://github.com/metacran/cranlogs.app)\n\n## 1. Installing \"ggtrendline\" package in R\n\n- Get the released version from CRAN:\n\n\t\tinstall.packages(\"ggtrendline\")\n\n- Or the development version from Github:\n\n\t\tinstall.packages(\"devtools\")\n\t\tdevtools::install_github(\"PhDMeiwp/ggtrendline@master\", force = TRUE)\n\t\tlibrary(ggtrendline)\n\n\n## 2. Using \"ggtrendline\" package\n\t\n     library(ggplot2)\n\t library(ggtrendline)\n     x \u003c- c(1, 3, 6, 9,  13,   17)\n     y \u003c- c(5, 8, 11, 13, 13.2, 13.5)\n\n### 2.1 default (\"line2P\")\n\n     ggtrendline(x, y, model = \"line2P\")  \n\n\u003ca href=\"https://sm.ms/image/4pICPTDh2gJxuFK\" target=\"_blank\"\u003e\u003cimg src=\"https://s2.loli.net/2022/04/13/4pICPTDh2gJxuFK.png\" \u003e\u003c/a\u003e\n\n\u003ca href=\"https://sm.ms/image/JOrRHYWGy8EMofs\" target=\"_blank\"\u003e\u003cimg src=\"https://s2.loli.net/2022/04/13/JOrRHYWGy8EMofs.png\" \u003e\u003c/a\u003e\n\n\n### 2.2 add geom_point()\n\n     ggtrendline(x, y, model = \"line3P\") + geom_point(aes(x, y)) + theme_bw()\n\n\u003ca href=\"https://sm.ms/image/Dp6Lt58jf9rmaNW\" target=\"_blank\"\u003e\u003cimg src=\"https://s2.loli.net/2022/04/13/Dp6Lt58jf9rmaNW.png\" \u003e\u003c/a\u003e\n\n### 2.3 CI lines only, without CI filling\n\n     ggtrendline(x, y, model = \"log2P\", CI.fill = NA) + \n\t\t\tgeom_point(aes(x, y))+ theme_classic() \n\t\n\u003ca href=\"https://sm.ms/image/VuDypF3tZWzK9B5\" target=\"_blank\"\u003e\u003cimg src=\"https://s2.loli.net/2022/04/13/VuDypF3tZWzK9B5.png\" \u003e\u003c/a\u003e\n\n### 2.4 set the regression line and geom_point()\n\n     ggtrendline(x, y, model = \"exp2P\", linecolor = \"blue\", linetype = 1, linewidth = 1) + \n             geom_point(aes(x, y), color = \"blue\", shape = 1, size = 3)  \n\n\u003ca href=\"https://sm.ms/image/TF48LAtiIHB1ukd\" target=\"_blank\"\u003e\u003cimg src=\"https://s2.loli.net/2022/04/13/TF48LAtiIHB1ukd.png\" \u003e\u003c/a\u003e\n\t\t\n### 2.5 set confidence interval\n\n     ggtrendline(x, y, model = \"exp3P\", CI.level = 0.99, \n                CI.fill = \"red\", CI.alpha = 0.1, CI.color = NA, CI.lty = 2, CI.lwd = 1.5) + \n             geom_point(aes(x, y)) \n\n\u003ca href=\"https://sm.ms/image/6ul7toUOWkhcw3s\" target=\"_blank\"\u003e\u003cimg src=\"https://s2.loli.net/2022/04/13/6ul7toUOWkhcw3s.png\" \u003e\u003c/a\u003e\n\t\t\n### 2.6 one trendline with different points belonged to multiple groups.\n\n\t\tlibrary(ggplot2)\n\t\tlibrary(ggtrendline)\n\t\tdata(\"iris\")\n\t\tx \u003c- iris$Petal.Width\n\t\ty \u003c- iris$Petal.Length\n\t\tgroup \u003c- iris$Species\n\t\tggtrendline(x,y,\"exp3P\") + geom_point(aes(x,y,color=group))\n\n\u003ca href=\"https://sm.ms/image/MYa9WHqlALfFXeD\" target=\"_blank\"\u003e\u003cimg src=\"https://s2.loli.net/2022/05/04/MYa9WHqlALfFXeD.png\" \u003e\u003c/a\u003e\n\n## 3. Details\n\n### 3.1 Description\n\nThe 'ggtrendline' package is developed for adding **trendline and confidence interval** of **linear or nonlinear regression** model, and\n    **showing equation, R square, and P value**  to 'ggplot' as simple as possible. \n\n\u003cbr\u003eFor a general overview of the methods used in this package, \n\tsee Ritz and Streibig (2008) \u003cdoi:10.1007/978-0-387-09616-2\u003e and \n\tGreenwell and Schubert Kabban (2014) \u003cdoi:10.32614/RJ-2014-009\u003e.\n\n### 3.2 ggtrendline function\n\nThe built-in 'ggtrendline()' function includes the following models:\u003cbr\u003e\n\u003cbr\u003e\"line2P\", formula as: y = a\\*x + b;\n\u003cbr\u003e\"line3P\", y = a\\*x^2 + b\\*x + c;\n\u003cbr\u003e\"log2P\" , y = a\\*ln(x) + b; \n\u003cbr\u003e\"exp2P\", y = a\\*exp(b\\*x); \n\u003cbr\u003e\"exp3P\", y = a\\*exp(b\\*x) + c;\n\u003cbr\u003e\"power2P\", y = a\\*x^b;\n\u003cbr\u003e\"power3P\", y = a\\*x^b + c.\n\n### 3.3 stat_eq and stat_rrp functions\n\n**The built-in 'stat_eq()' and 'stat_rrp()' functions can be used separately, i.e., not together with 'ggtrendline()' function.**\n\nTo see more details, you can run the following R code if you have the \"ggtrendline\" package installed:\n\n    library(ggtrendline)\n    ?ggtrendline\n\t?stat_eq\n\t?stat_rrp\n\n## 4. Contact\n\n- Bugs and feature requests can be filed to https://github.com/PhDMeiwp/ggtrendline/issues. \n- BTW, [Pull requests](https://github.com/PhDMeiwp/ggtrendline/pulls) are also welcome.\n\n## 5. Acknowledgements\n\nWe would like to express our special thanks to **Uwe Ligges, Gregor Seyer, and CRAN team** for their valuable comments to the 'ggtrendline' package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPhDMeiwp%2Fggtrendline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPhDMeiwp%2Fggtrendline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPhDMeiwp%2Fggtrendline/lists"}