{"id":18430131,"url":"https://github.com/friendly/guerry","last_synced_at":"2025-04-13T22:41:46.568Z","repository":{"id":47100291,"uuid":"133678938","full_name":"friendly/Guerry","owner":"friendly","description":"Maps, data and methods related to Guerry (1833) \"Moral Statistics of France\"","archived":false,"fork":false,"pushed_at":"2025-01-02T22:48:47.000Z","size":17217,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-10T10:44:56.516Z","etag":null,"topics":["france","moral-statistics","multivariate-spatial-analysis"],"latest_commit_sha":null,"homepage":"https://friendly.github.io/Guerry/","language":"TeX","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/friendly.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"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":"2018-05-16T14:34:29.000Z","updated_at":"2025-01-02T22:48:51.000Z","dependencies_parsed_at":"2023-10-14T16:42:33.899Z","dependency_job_id":"e1accc4a-e4c2-4de9-b248-72c6322885b2","html_url":"https://github.com/friendly/Guerry","commit_stats":{"total_commits":169,"total_committers":5,"mean_commits":33.8,"dds":"0.14792899408284022","last_synced_commit":"e161f787735e7b846cf5ae1ce9aa387d88f838bb"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2FGuerry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2FGuerry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2FGuerry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2FGuerry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friendly","download_url":"https://codeload.github.com/friendly/Guerry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794565,"owners_count":21162613,"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":["france","moral-statistics","multivariate-spatial-analysis"],"created_at":"2024-11-06T05:19:41.131Z","updated_at":"2025-04-13T22:41:46.531Z","avatar_url":"https://github.com/friendly.png","language":"TeX","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  warning = FALSE,   # avoid warnings and messages in the output\n  message = FALSE,\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  width = 90,        # line width for text output\n  dpi = 96\n)\n\npar(mar=c(3,3,1,1)+.1)\n```\n\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/Guerry)](https://cran.r-project.org/package=Guerry)\n[![](https://cranlogs.r-pkg.org/badges/grand-total/Guerry)](https://cran.r-project.org/package=Guerry)\n[![DOI](https://zenodo.org/badge/133678938.svg)](https://zenodo.org/badge/latestdoi/133678938)\n[![Last Commit](https://img.shields.io/github/last-commit/friendly/Guerry)](https://github.com/friendly/Guery)\n\n\n\u003c!-- badges: end --\u003e\n\n\n# Guerry \u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"200px\" /\u003e\n\n**Version**: 1.8.4\n\u003c!-- `r getNamespaceVersion(\"Guerry\")` --\u003e\n\nThe `Guerry` package comprises maps of France in 1830, multivariate data from A.-M. Guerry and others, and statistical and \n\tgraphic methods related to Guerry's *Moral Statistics of France*. The goal is to facilitate the exploration and\n\tdevelopment of statistical and graphic methods for multivariate data in a geo-spatial context of historical interest.\n\t\nThe package stems from [Friendly (2007)](https://www.datavis.ca/papers/guerry-STS241.pdf). For a history of André-Michel Guerry and his work, see Friendly (2022), [_The Life and Work of André-Michel Guerry, Revisited_](https://www.datavis.ca/papers/guerryvie/GuerryLife2-SocSpectrum.pdf).\n\nThis figure shows a reproduction of six choropleth maps Guerry used to discuss\nthe relations among the main \"moral variables\". All of these are scaled so that\nmore is better. Guerry asked, do such patterns reflect simply individual behavior,\nor are there laws to be discovered in his data?\n\n\u003cimg src=\"man/figures/Guerry-vars.png\" align=\"center\" /\u003e\n\n\n\n## Installation\n\n\nYou can install Guerry from CRAN or the development version as follows:\n\n| Version     | Command                                         |\n|:------------|:------------------------------------------------|\n| CRAN        | `install.packages(\"Guerry\")`                    |\n| Devel       | `remotes::install_github(\"friendly/Guerry\")`    |\n| R-universe  | `install.packages('Guerry', repos = c('https://friendly.r-universe.dev'))` |\n\n\n## Data sets\n\nThe Guerry package contains the following data sets:\n\n|Name  | Description |\n|:-----|:------------|\n| `gfrance`  | Map of France in 1830 with the `Guerry` data. It is a `SpatialPolygonsDataFrame` object created with the `sp` package.|\n| `gfrance85`| The same for the 85 departments excluding Corsica|\n| `Guerry`   | A collection of 'moral variables' on the 86 departments of France around 1830 from Guerry (1833) and other sources.|\n| `Guerry_ranks` | Data in `Guerry` with all numeric variables converted to ranks.\n| `Angeville`| Data from d'Angeville (1836) on the population of France.|\n| `propensity` | Distribution of crimes against persons at different ages |\n\n\n\n## Examples\n\n### Maps\n\nIn Guerry's time, the map of France and his data contained 86 departments.\nThe two base maps in this package are `gfrance` and `gfrance85`. They differ only in that Corsica,\noutside the continental boundaries, is excluded in the later.\n\nThese two datasets are `SpatialPolygonsDataFrame`s constructed with the [`sp`](https://cran.r-project.org/package=sp) \npackage.  This means\nthey contain S4 components and have S4 methods\n\n* `gfrance@polygons` the polygon boundaries of the of the 1830 map of France\n* `gfrance@data` equivalent to the variables contained in the `Guerry` data set\n\n```{r}\n#| width=100\ndata(gfrance)\nnames(gfrance)  # list the @data variables\n```\n\nThus, you can can just use `plot(gfrance)` to plot the outlines of the departments,\n\n```{r gfrance1}\nlibrary(sp)\nplot(gfrance)\n```\n\nThe `spplot` method produces a choropleth map, shaded by a given variable in `gfrance@data`\n\n```{r gfrance2}\nspplot(gfrance, \"Crime_pers\")\n```\n\nYou can plot the maps for several variables together simply by listing their names in a vector.\n\n```{r gfrance3}\n# plot several together\nspplot(gfrance, c(\"Crime_pers\", \"Crime_prop\", \"Literacy\" ), \n       layout=c(3,1), main=\"Guerry's moral variables\")\n```\n\nBut there's a problem here.  `spplot` assumes all variables are on the same scale for comparative plots, so\nit is best to transform variables to ranks (as Guerry did).\nAs well, use something like Guerry's pallet, where dark = Worse.\n\n```{r gfrance4}\ngfrance$Crime_pers \u003c- rank(gfrance$Crime_pers)\ngfrance$Crime_prop \u003c- rank(gfrance$Crime_prop)\ngfrance$Literacy   \u003c- rank(gfrance$Literacy)\n\nmy.palette \u003c- rev(RColorBrewer::brewer.pal(n = 9, name = \"PuBu\"))\nspplot(gfrance, c(\"Crime_pers\", \"Crime_prop\", \"Literacy\" ), \n       names.attr = c(\"Personal crime\", \"Property crime\", \"Literacy\"),\n       col.regions = my.palette, cuts = 8,\n       layout=c(3,1), as.table=TRUE, main=\"Guerry's moral variables\")\n```\n\nFor other purposes, you might want to produce the map, shaded by `Region` and adding labels\nfor the names of the departments.  This is illustrated using the `gfrance85` map (excluding Corsica), where\n`coordinates()` gets the (X, Y) coordinates of the centroids for each department, \nand `text()` for the `sp` object plots the labels.\n\n```{r gfrance85-labels}\n#| echo=-1\nop \u003c-par(mar=rep(0.1,4))\ndata(gfrance85)\n# extract region and dept names \u0026 assign colors\nxy            \u003c- coordinates(gfrance85)            # department centroids\ndep.names     \u003c- data.frame(gfrance85)[,6]\nregion.names  \u003c- data.frame(gfrance85)[,5]\ncol.region    \u003c- colors()[c(149,254,468,552,26)]   # assign colors\n\nplot(gfrance85, col=col.region[region.names])\ntext(xy, labels=dep.names, cex=0.5)\n```\n\n\n### Plots\n\nGuerry was most interested in determining whether the occurrence of crimes\nwas related to literacy or other \"moral variables\".  But the idea of\ncorrelation had not been invented, and he was not aware of the\nidea of a scatterplot. \n\nPlotting crimes against persons vs. Literacy (\"% who can read \u0026 write\").\nIn this base R version, we might want to code the point symbols \nand colors by regions of France.\n\n```{r ex-bivar1}\n#| out.width=\"60%\",\n#| fig.height = 5,\n#| fig.width = 5,\n#| echo=-1\npar(mar=c(4,4,1,1)+.1)\ndata(Guerry)\n\nplot(Crime_pers ~ Literacy, data=Guerry,\n\tcol=Region, \n\tpch=(15:19)[Region],\n\tylab = \"Pop. per crime against persons\",\n\txlab = \"Percent who can read \u0026 write\"\n\t)\n\nlegend(x=\"bottomright\", \n\tlegend = c(\"Center\", \"East\", \"North\", \"South\", \"West\"), \n\tpch = 15:19,\n\tcol = as.factor(levels(Guerry$Region)))\n```\n\n\u003c!-- Old plot: --\u003e\n\u003c!-- \u003cimg src=\"man/figures/ex-bivar1.png\" align=\"center\" height=\"400px\" /\u003e --\u003e\n\nNow try this with a data ellipse, and a regression line. This version also uses a\na `loess` smooth and labels the 8 most outlying departments.\n\n```{r ex-bivar2}\n#| out.width=\"60%\",\n#| fig.height = 5,\n#| fig.width = 5,\n#| echo = -1\npar(mar=c(4,4,1,1)+.1)\nlibrary(car)\nwith(Guerry,{\n  dataEllipse(Literacy, Crime_pers,\n      levels = 0.68,\n      ylim = c(0,40000), xlim = c(0, 80),\n      ylab=\"Pop. per crime against persons\",\n      xlab=\"Percent who can read \u0026 write\",\n      pch = 16,\n      grid = FALSE,\n      id = list(method=\"mahal\", \n                n = 8, labels=Department, location=\"avoid\", cex=1.2),\n      center.pch = 3, center.cex=5,\n      cex.lab=1.5)\n      \n  dataEllipse(Literacy, Crime_pers,\n      levels = 0.95, add=TRUE,\n      ylim = c(0,40000), xlim = c(0, 80),\n      lwd=2, lty=\"longdash\",\n      col=\"gray\",\n      center.pch = FALSE\n      )\n\n  abline( lm(Crime_pers ~ Literacy), lwd=2)\t\n  lines(loess.smooth(Literacy, Crime_pers), col=\"red\", lwd=3)\n  }\n  \t)\n```\n\n\u003c!-- Old plot: --\u003e\n\u003c!-- \u003cimg src=\"man/figures/ex-bivar2.png\" align=\"center\" height=\"400px\" /\u003e --\u003e\n\n## Vignettes\n\nThe vignette, _Guerry data: Spatial Multivariate Analysis_, written by Stéphane Dray uses his packages\n`ade4` and `adegraphics` to illustrate methods for spatial multivariate data that focus on either\nthe multivariate aspect or the spatial one, as well as some more modern methods that integrate\nthese simultaneously. \n\nA new vignette, _Guerry data: Multivariate Analysis_, uses Guerry's data to illustrate some graphical\nmethods for multivariate visualization.\n\nSee:\n\n\n``` r\nvignette(\"MultiSpat\", package=\"Guerry\")\nvignette(\"guerry-multivariate\", package=\"Guerry\")\n```\n\n## Citation\n\n``` r\nTo cite package ‘Guerry’ in publications use:\n\n  Friendly M, Dray S (2021). _Guerry: Maps, Data and Methods Related to Guerry (1833) \"Moral Statistics\n  of France\"_. R package version 1.7.4, \u003chttps://CRAN.R-project.org/package=Guerry\u003e.\n\nA BibTeX entry for LaTeX users is\n\n  @Manual{,\n    title = {Guerry: Maps, Data and Methods Related to Guerry (1833) \"Moral Statistics of France\"},\n    author = {Michael Friendly and Stéphane Dray},\n    year = {2021},\n    note = {R package version 1.7.4},\n    url = {https://CRAN.R-project.org/package=Guerry},\n  }\n```\n\n## References\n\nAngeville, A. d' (1836).\n_Essai sur la Statistique de la Population francaise_, Paris: F. Darfour.\n\nFriendly, M. (2007). A.-M. Guerry's Moral Statistics of France: Challenges for Multivariable Spatial Analysis.\n *Statistical Science*, **22**, 368-399. https://www.datavis.ca/papers/guerry-STS241.pdf\n\nFriendly, M. (2007).\nSupplementary materials for Andre-Michel Guerry's *Moral Statistics of France*:\nChallenges for Multivariate Spatial Analysis,\nhttps://www.datavis.ca/gallery/guerry/.\n\nFriendly, M. (2022). The Life and Work of André-Michel Guerry, Revisited. \n*Sociological Spectrum*, **42** (1).\nhttps://www.tandfonline.com/doi/full/10.1080/02732173.2022.2078450.\n[eprint](https://www.datavis.ca/papers/guerryvie/GuerryLife2-SocSpectrum.pdf)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendly%2Fguerry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriendly%2Fguerry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendly%2Fguerry/lists"}