Skip to content

Commit

Permalink
refactor: manually supply date-modified dates instead
Browse files Browse the repository at this point in the history
This might just be the right thing to do generally anyway.
  • Loading branch information
jolars committed May 31, 2024
1 parent c738d1f commit c39b05c
Show file tree
Hide file tree
Showing 21 changed files with 18 additions and 12 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": "5413aae9fd2d6c2a1221670b83d3631b",
"hash": "d6843746bd163154915c5d34a2055a97",
"result": {
"engine": "knitr",
"markdown": "---\ntitle: \"Introducing eulerr\"\nauthor: \"Johan Larsson\"\ndate: \"2016-10-19\"\ndescription: |\n This is an introduction to my new package, eulerr, an R package that computes\n and plots eulerr diagrams of set relationships.\ncategories:\n - r\n - eulerr\n - euler diagrams\n - data visualization\nimage: eulerr.svg\n---\n\n\n\n\n**eulerr** is an [R](https://www.r-project.org) package that generates\narea-proportional euler diagrams to display set\nrelationships (intersections, unions, and disjoints) with circles.\n[Euler diagrams](https://en.wikipedia.org/wiki/Euler_diagram) are Venn\ndiagrams without the requirement that all set interactions be present (whether\nthey are empty or not). That is, depending on input, eulerr will sometimes\nproduce Venn diagrams but sometimes not.\n\n## Background\n\nR features a number of packages that produce Euler and/or Venn diagrams;\nsome of the more prominent ones (on CRAN) are\n\n* [eVenn](https://cran.r-project.org/package=eVenn),\n* [VennDiagram](https://cran.r-project.org/package=VennDiagram),\n* [venn](https://cran.r-project.org/package=venn),\n* [colorfulVennPlot](https://cran.r-project.org/package=colorfulVennPlot), and\n* [venneuler](https://cran.r-project.org/package=venneuler).\n\nThe last of these (venneuler) serves as the primary inspiration for this package,\nalong with the refinements that Ben Fredrickson has presented on his\n[blog](http://www.benfrederickson.com/) and made available in his javascript\n[venn.js](https://github.com/benfred/venn.js).\n\nvenneuler, however, is written in java, preventing R users from \nbrowsing the source code (unless they are also literate in java) or\ncontributing. Furthermore, venneuler is known to produce imperfect output for\nset configurations that have perfect solutions. Consider,\nfor instance, the following example in which the intersection between `A` and\n`B` is unwanted.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nlibrary(venneuler, quietly = TRUE)\nvenn_fit <- venneuler(c(A = 75, B = 50, \"A&B\" = 0))\nplot(venn_fit)\n```\n\n::: {.cell-output-display}\n![venneuler plot with unwanted overlap.](index_files/figure-html/unnamed-chunk-2-1.png){fig-align='center' width=384}\n:::\n:::\n\n\n## Enter eulerr\n\neulerr is based on the improvements to **venneuler** that Ben Fredrickson\nintrocued with **venn.js** but has been coded from scratch, uses different\noptimizers, and returns the residuals and stress statistic that venneuler\nfeatures. \n\n### Input\n\nCurrently, it is possible to provide input to `eulerr` as either\n\n* a named numeric vector or\n* a matrix of logicals with columns representing sets and rows the set\nrelationships for each observation.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nlibrary(eulerr)\n\n# Input in the form of a named numeric vector\nfit1 <- euler(c(\"A\" = 25, \"B\" = 5, \"C\" = 5,\n \"A&B\" = 5, \"A&C\" = 5, \"B&C\" = 3,\n \"A&B&C\" = 3))\n\n# Input as a matrix of logicals\nset.seed(1)\nmat <-\n cbind(\n A = sample(c(TRUE, TRUE, FALSE), size = 50, replace = TRUE),\n B = sample(c(TRUE, FALSE), size = 50, replace = TRUE),\n C = sample(c(TRUE, FALSE, FALSE, FALSE), size = 50, replace = TRUE)\n )\nfit2 <- euler(mat)\n```\n:::\n\n\n### Fit\n\nWe inspect our results by printing the eulerr object\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nfit2\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n original fitted residuals regionError\nA 13 13 0 0.008\nB 4 4 0 0.002\nC 0 0 0 0.000\nA&B 17 17 0 0.010\nA&C 5 5 0 0.003\nB&C 1 0 1 0.024\nA&B&C 2 2 0 0.001\n\ndiagError: 0.024 \nstress: 0.002 \n```\n\n\n:::\n:::\n\n\nor directly access and plot the residuals.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\n# Cleveland dot plot of the residuals\ndotchart(resid(fit2))\n\nabline(v = 0, lty = 3)\n```\n\n::: {.cell-output-display}\n![Residuals for the eulerr fit.](index_files/figure-html/residual_plot-1.png){fig-align='center' width=384}\n:::\n:::\n\n\nThis shows us that the `A&B&C` intersection is somewhat overrepresented in\n`fit2`. Given that these residuals are on the scale of the original\nvalues, however, the residuals are arguably of little concern.\n\nFor an overall measure of the fit of the solution, we use the same stress\nstatistic that Leland Wilkinson presented in his academic paper on venneuler \n[@wilkinson2012], which is given by the sums of squared residuals divided\nby the total sums of squares:\n\n$$\\frac{\\sum_{i=1}^n (f_i - y_i)^2}{\\sum_{i=1}^n (y_i - \\bar{y})^2}.$$\n\nWe fetch it from the `stress` attribute of the `eulerr` object.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nfit2$stress\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 0.00198\n```\n\n\n:::\n:::\n\n\nWe can now be confident that eulerr provides a reasonable representation of\nour input. Were it otherwise, we would do best to stop here and look for another\nway to visualize our data. (I suggest the excellent\n[UpSetR](https://cran.r-project.org/package=UpSetR) package.)\n\n### Plotting\n\nNo we get to the fun part: plotting our diagram. This is easy, as well as\nhighly customizable, with eulerr.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nplot(fit2)\n\n# Change fill colors, border type (remove) and fontface.\nplot(\n fit2,\n fills = c(\"dodgerblue4\", \"plum2\", \"seashell2\"),\n edges = list(lty = 1:3),\n labels = list(font = 2)\n)\n```\n\n::: {.cell-output-display}\n![eulerr plots can be modified in many ways.](index_files/figure-html/eulerr_plot-1.png){fig-align='center' width=240}\n:::\n\n::: {.cell-output-display}\n![eulerr plots can be modified in many ways.](index_files/figure-html/eulerr_plot-2.png){fig-align='center' width=240}\n:::\n:::\n\n\neulerr's default color palette is taken from\n[qualpalr](https://cran.r-project.org/package=qualpalr) -- another\npackage that I have developed -- which uses color difference algorithms to \ngenerate distinct qualitative color palettes.\n\n## Details\n\nDetails of the implementation will be left for a future vignette but almost\ncompletely resemble the approach documented\n[here](http://www.benfrederickson.com/better-venn-diagrams/).\n\n## Thanks\n\neulerr would not be possible without Ben Fredrickson's work on\n[venn.js](http://www.benfrederickson.com) or Leland Wilkinson's\n[venneuler](https://cran.r-project.org/package=venneuler).\n\n## References\n\n",
"markdown": "---\ntitle: \"Introducing eulerr\"\nauthor: \"Johan Larsson\"\ndate: \"2016-10-19\"\ndate-modified: \"2023-01-17\"\ndescription: |\n This is an introduction to my new package, eulerr, an R package that computes\n and plots eulerr diagrams of set relationships.\ncategories:\n - r\n - eulerr\n - euler diagrams\n - data visualization\nimage: eulerr.svg\n---\n\n\n\n\n**eulerr** is an [R](https://www.r-project.org) package that generates\narea-proportional euler diagrams to display set\nrelationships (intersections, unions, and disjoints) with circles.\n[Euler diagrams](https://en.wikipedia.org/wiki/Euler_diagram) are Venn\ndiagrams without the requirement that all set interactions be present (whether\nthey are empty or not). That is, depending on input, eulerr will sometimes\nproduce Venn diagrams but sometimes not.\n\n## Background\n\nR features a number of packages that produce Euler and/or Venn diagrams;\nsome of the more prominent ones (on CRAN) are\n\n* [eVenn](https://cran.r-project.org/package=eVenn),\n* [VennDiagram](https://cran.r-project.org/package=VennDiagram),\n* [venn](https://cran.r-project.org/package=venn),\n* [colorfulVennPlot](https://cran.r-project.org/package=colorfulVennPlot), and\n* [venneuler](https://cran.r-project.org/package=venneuler).\n\nThe last of these (venneuler) serves as the primary inspiration for this package,\nalong with the refinements that Ben Fredrickson has presented on his\n[blog](http://www.benfrederickson.com/) and made available in his javascript\n[venn.js](https://github.com/benfred/venn.js).\n\nvenneuler, however, is written in java, preventing R users from \nbrowsing the source code (unless they are also literate in java) or\ncontributing. Furthermore, venneuler is known to produce imperfect output for\nset configurations that have perfect solutions. Consider,\nfor instance, the following example in which the intersection between `A` and\n`B` is unwanted.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nlibrary(venneuler, quietly = TRUE)\nvenn_fit <- venneuler(c(A = 75, B = 50, \"A&B\" = 0))\nplot(venn_fit)\n```\n\n::: {.cell-output-display}\n![venneuler plot with unwanted overlap.](index_files/figure-html/unnamed-chunk-2-1.png){fig-align='center' width=384}\n:::\n:::\n\n\n## Enter eulerr\n\neulerr is based on the improvements to **venneuler** that Ben Fredrickson\nintrocued with **venn.js** but has been coded from scratch, uses different\noptimizers, and returns the residuals and stress statistic that venneuler\nfeatures. \n\n### Input\n\nCurrently, it is possible to provide input to `eulerr` as either\n\n* a named numeric vector or\n* a matrix of logicals with columns representing sets and rows the set\nrelationships for each observation.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nlibrary(eulerr)\n\n# Input in the form of a named numeric vector\nfit1 <- euler(c(\"A\" = 25, \"B\" = 5, \"C\" = 5,\n \"A&B\" = 5, \"A&C\" = 5, \"B&C\" = 3,\n \"A&B&C\" = 3))\n\n# Input as a matrix of logicals\nset.seed(1)\nmat <-\n cbind(\n A = sample(c(TRUE, TRUE, FALSE), size = 50, replace = TRUE),\n B = sample(c(TRUE, FALSE), size = 50, replace = TRUE),\n C = sample(c(TRUE, FALSE, FALSE, FALSE), size = 50, replace = TRUE)\n )\nfit2 <- euler(mat)\n```\n:::\n\n\n### Fit\n\nWe inspect our results by printing the eulerr object\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nfit2\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n original fitted residuals regionError\nA 13 13 0 0.008\nB 4 4 0 0.002\nC 0 0 0 0.000\nA&B 17 17 0 0.010\nA&C 5 5 0 0.003\nB&C 1 0 1 0.024\nA&B&C 2 2 0 0.001\n\ndiagError: 0.024 \nstress: 0.002 \n```\n\n\n:::\n:::\n\n\nor directly access and plot the residuals.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\n# Cleveland dot plot of the residuals\ndotchart(resid(fit2))\n\nabline(v = 0, lty = 3)\n```\n\n::: {.cell-output-display}\n![Residuals for the eulerr fit.](index_files/figure-html/residual_plot-1.png){fig-align='center' width=384}\n:::\n:::\n\n\nThis shows us that the `A&B&C` intersection is somewhat overrepresented in\n`fit2`. Given that these residuals are on the scale of the original\nvalues, however, the residuals are arguably of little concern.\n\nFor an overall measure of the fit of the solution, we use the same stress\nstatistic that Leland Wilkinson presented in his academic paper on venneuler \n[@wilkinson2012], which is given by the sums of squared residuals divided\nby the total sums of squares:\n\n$$\\frac{\\sum_{i=1}^n (f_i - y_i)^2}{\\sum_{i=1}^n (y_i - \\bar{y})^2}.$$\n\nWe fetch it from the `stress` attribute of the `eulerr` object.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nfit2$stress\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 0.00198\n```\n\n\n:::\n:::\n\n\nWe can now be confident that eulerr provides a reasonable representation of\nour input. Were it otherwise, we would do best to stop here and look for another\nway to visualize our data. (I suggest the excellent\n[UpSetR](https://cran.r-project.org/package=UpSetR) package.)\n\n### Plotting\n\nNo we get to the fun part: plotting our diagram. This is easy, as well as\nhighly customizable, with eulerr.\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nplot(fit2)\n\n# Change fill colors, border type (remove) and fontface.\nplot(\n fit2,\n fills = c(\"dodgerblue4\", \"plum2\", \"seashell2\"),\n edges = list(lty = 1:3),\n labels = list(font = 2)\n)\n```\n\n::: {.cell-output-display}\n![eulerr plots can be modified in many ways.](index_files/figure-html/eulerr_plot-1.png){fig-align='center' width=240}\n:::\n\n::: {.cell-output-display}\n![eulerr plots can be modified in many ways.](index_files/figure-html/eulerr_plot-2.png){fig-align='center' width=240}\n:::\n:::\n\n\neulerr's default color palette is taken from\n[qualpalr](https://cran.r-project.org/package=qualpalr) -- another\npackage that I have developed -- which uses color difference algorithms to \ngenerate distinct qualitative color palettes.\n\n## Details\n\nDetails of the implementation will be left for a future vignette but almost\ncompletely resemble the approach documented\n[here](http://www.benfrederickson.com/better-venn-diagrams/).\n\n## Thanks\n\neulerr would not be possible without Ben Fredrickson's work on\n[venn.js](http://www.benfrederickson.com) or Leland Wilkinson's\n[venneuler](https://cran.r-project.org/package=venneuler).\n\n## References\n\n",
"supporting": [
"index_files"
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c39b05c

Please sign in to comment.