{"id":13400896,"url":"https://github.com/yeukyul/lindia","last_synced_at":"2026-02-25T16:03:08.518Z","repository":{"id":56937493,"uuid":"79866870","full_name":"yeukyul/lindia","owner":"yeukyul","description":"Extension package of linear regression diagonostic plots in ggplot2.","archived":false,"fork":false,"pushed_at":"2023-08-14T19:00:14.000Z","size":6577,"stargazers_count":102,"open_issues_count":2,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T05:03:32.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/yeukyul.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"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}},"created_at":"2017-01-24T01:26:38.000Z","updated_at":"2025-09-04T23:46:20.000Z","dependencies_parsed_at":"2024-01-18T04:08:10.119Z","dependency_job_id":"16708cf4-8f21-4d3b-8e76-3cec95497830","html_url":"https://github.com/yeukyul/lindia","commit_stats":{"total_commits":66,"total_committers":3,"mean_commits":22.0,"dds":0.0757575757575758,"last_synced_commit":"9853c34ff2568e95ad9aa3649f779d84ea838bff"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/yeukyul/lindia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeukyul%2Flindia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeukyul%2Flindia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeukyul%2Flindia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeukyul%2Flindia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeukyul","download_url":"https://codeload.github.com/yeukyul/lindia/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeukyul%2Flindia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29829408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T15:41:19.027Z","status":"ssl_error","status_checked_at":"2026-02-25T15:40:47.150Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-07-30T19:00:56.743Z","updated_at":"2026-02-25T16:03:08.493Z","avatar_url":"https://github.com/yeukyul.png","language":"R","funding_links":[],"categories":["R","Data and models"],"sub_categories":[],"readme":"---\noutput:\n  md_document:\n    variant: markdown_github\n---\n\n```{r, echo = FALSE, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE, \n  comment = \"# \",\n  fig.path = \"figures/README-\"\n)\n\nlibrary(ggplot2)\nlibrary(lindia)\ndata(Cars93)\n\n```\n\n\n#lindia\n\nlindia is an extention to [**ggplot2**](http://ggplot2.org) to provide streamlined plotting features of linear model diagnostic plots. The following demonstrates basic plotting features of `lindia`. All functions in `lindia` takes in an lm object (including `lm()` and `glm()`) and returns linear diagnostic plots in forms of `ggplot` objects. The following code demonstrates how you can create a simple linear model from `Cars93` dataset, then use a call to `lindia::gg_diagnose()` to visualize overall features of the distribution.\n\n```{r, warning = F, message = F, fig.width = 12, fig.height = 10}\n# create linear model\ncars_lm \u003c- lm(Price ~ Passengers + Length + RPM, data = Cars93)\n\n# visualize diagnostic plots with a call to lindia\ngg_diagnose(cars_lm)\n```\n\nThe functionality of lindia is an improvement of the features provided in base-R graphs. Using base-R, user can also create a series of diagnostic plots using the following line: \n\n```{r, warning = F, message = F, fig.width = 12, fig.height = 10}\npar(mfrow = c(2,2))\nplot(cars_lm)\n```\n\nHowever, the output from a call to `plot()` lacks flexibility and comprehensiveness. For example, residual vs. predictor plots are not shown, and that users cannot easily maipulate graph type and aesthetics. In that sense, `lindia` is an extension to features offered in base-R.\n\n#Installation\n\n+ From Github:  `devtools::install_github(\"yeukyul/lindia\")`\n\n\n#Overview\nFollowed are functions implemented in `lindia`:\n\n+ [`gg_reshist()`](#gg_reshist): Histogram of residuals\n+ [`gg_resfitted()`](#gg_resfitted): Residual plot of residuals by fitted value\n+ [`gg_resX()`](#gg_resX): All residual plots of all predictors by fitted value, layed out in a grid\n+ [`gg_qqplot()`](#gg_qqplot): Normaility quantile-quantile plot (QQPlot) with qqline overlayed on top\n+ [`gg_boxcox()`](#gg_boxcox): Boxcox graph with optimal transformation labeled on graph\n+ [`gg_scalelocation()`](#gg_scalelocation): Scale-location plot (also called spread-location plot)\n+ [`gg_resleverage()`](#gg_resleverage): Residual by leverage plot\n+ [`gg_cooksd()`](#gg_cooksd): Cook's distance plot with potential outliars labeled on top\n+ [`gg_diagnose()`](#gg_diagnose): All diagnostic plots, layed out in a grid\n\n`gg_resX()` and `gg_diagnose()` would return multiple plots after a call to the function. By default, they would return one aggregate plot of all diagnostic plots as one arranged grid. If user needs more flexibility in determining graphical elements and inclusion/exclusion of certain plots, set `plot.all` parameter in the function call to `FALSE`. It will return a list of all plots, which user can manipulate. \n\n\nAn example would as be followed:\n```{r, warning = F, message = F}\nplots \u003c- gg_diagnose(cars_lm, plot.all = FALSE)\nnames(plots)\nexclude_plots \u003c- plots[-c(1, 3)]    # exclude certain diagnostics plots\ninclude_plots \u003c- plots[c(1, 3)]      # include certain diagnostics plots\n```\n\n\nIn addition, `lindia` provides a `plot_all()` feature that allows user to pass in a list of plots and output as a formatted grid of plots using `gridExtra::grid.arrange()`.\n```{r, warning = F, message = F, fig.width = 12, fig.height = 8}\nplot_all(exclude_plots)\n```\n\nAll graphical styles returned by lindia graphing function can be overwritten by a call to `ggplot::theme()` (except `gg_resX()` and `gg_diagnose()`, which would return a list rather than a single ggplot object).\n```{r, warning = F, message = F}\ngg_resfitted(cars_lm) + theme_bw()\n```\n\n#Functions in Lindia\n\n\nThe following gives a brief demonstration of how to use the functions provided in `lindia`.\n\n#gg_reshist\n\nPlots distribution of residuals in histograms. Number of bins picked by default.\n```{r, warning = F, message = F}\ngg_reshist(cars_lm)\n```\n\nCan also specify number of bins using `bins` argument:\n```{r, warning = F, message = F}\ngg_reshist(cars_lm, bins = 20)\n```\n\n#gg_resX\n\nPlots residual plots of all predictors vs. residuals and return all plots as one plot that is arranged by package `gridExtra`. If a variable is continuous, it would be plotted as scatterplot.  If a given variable is category is categorical, lindia would plot boxplot for that variable.\n```{r, warning = F, message = F}\ncars_lm_2 \u003c- lm(Price ~ Passengers + Length + RPM + Origin, data = Cars93)\ngg_resX(cars_lm)\n```\n\n\n`lindia` can also handle linear models with interaction terms.\n\n```{r, warning = F, message = F}\ncars_lm_inter \u003c- lm(Price ~ Passengers * Length, data = Cars93)\ngg_resX(cars_lm_inter)\n```\n\n\n#gg_resfitted\n\nPlots residual against fitted value.\n```{r, warning = F, message = F}\ngg_resfitted(cars_lm)\n```\n\n\n#gg_qqplot\n\nPlots quantile quantile plot of a linear model, with qqline overlayed on top.\n\n```{r, warning = F, message = F}\ngg_qqplot(cars_lm)\n```\n\n#gg_boxcox\n\nPlots boxcox graph of given lm object, with labels showing optimal transforming power of response variable using box-cox transformation. Can hide labels on graph by setting `showlambda` to `FALSE`.\n```{r, warning = F, message = F}\ngg_boxcox(cars_lm)\n```\n\n#gg_scalelocation\n\nPlots scale location graph of linear model.\n\n```{r, warning = F, message = F}\ngg_scalelocation(cars_lm)\n```\n\n\n#gg_resleverage\n\nPlots residual vs. leverage of data points to detect outliers using cook's distance.\n\n```{r, warning = F, message = F}\ngg_resleverage(cars_lm)\n```\n\n#gg_cooksd\n\nPlots cook's distance plot that helps identify outliers. Observation numbers are plotted next to data points that are considered anamolies.\n\n```{r, warning = F, message = F}\ngg_cooksd(cars_lm)\n```\n\n\n#gg_diagnose\n\nAn aggregate plot of all diagnostics plots, layed out on one panel as demonstrated in the beginning of this README document. User can set `theme` parameter to a specific theme type in order to apply to all plots in the panel.\n\n```{r, warning = F, message = F, fig.width = 12, fig.height = 10}\ngg_diagnose(cars_lm_2, theme = theme_bw())\n```\n\nIf user set `plot.all` parameter to false, `gg_diagnose` would return a list of ggplot objects which user can manipulate. `lindia` also provides a handy trick that allows user to scale all point sizes and linewidth at once, using the parameter `scale.factor`. Followed is an extreme example by setting `scale.factor` to 0.3.\n\n```{r, warning = F, message = F, fig.width = 12, fig.height = 10}\ngg_diagnose(cars_lm_2, theme = theme_bw(), scale.factor = 0.3)\n```\n\n\n#Package Dependency\n\nLindia is built on top of the following few packages:\n\n+ `ggplot2`: ver 2.1.0\n\n+ `gridExtra`: ver 2.1.1\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeukyul%2Flindia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeukyul%2Flindia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeukyul%2Flindia/lists"}