Skip to content

Commit

Permalink
started visualizing distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
clauswilke committed Jan 2, 2025
1 parent b50a273 commit dbde4b2
Show file tree
Hide file tree
Showing 17 changed files with 3,173 additions and 248 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"hash": "cab9e91db3e9e715a9c0b014686f650f",
"result": {
"engine": "knitr",
"markdown": "---\ntitle: \"Visualizing distributions 1\"\nauthor: \"Claus O. Wilke\"\ndate: last-modified\nformat: \n revealjs:\n theme:\n - default\n - Wilke-theme.scss\n auto-stretch: false\n chalkboard: true\nexecute:\n fig-format: svg\n fig-asp: 0.618\n fig-width: 5.5\n---\n\n\n\n\n\n# Histograms and density plots\n\n## Passengers on the Titanic\n\n:::: {.columns}\n\n::: {.column width=\"30%\" .xtiny-font}\n\n\n::: {.cell}\n::: {.cell-output-display}\n`````{=html}\n<table>\n <thead>\n <tr>\n <th style=\"text-align:right;\"> age </th>\n <th style=\"text-align:left;\"> sex </th>\n <th style=\"text-align:left;\"> class </th>\n <th style=\"text-align:left;\"> survived </th>\n </tr>\n </thead>\n<tbody>\n <tr>\n <td style=\"text-align:right;\"> 0.2 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 0.3 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 0.8 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 0.8 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 0.8 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 0.9 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 1st </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 1.0 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 1.0 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 1.0 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 1.0 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 1.0 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 1.5 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 1.5 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 2.0 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 1st </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 2.0 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n</tbody>\n</table>\n\n`````\n:::\n:::\n\n\n:::\n\n::: {.column width=\"30%\" .xtiny-font}\n\n\n::: {.cell}\n::: {.cell-output-display}\n`````{=html}\n<table>\n <thead>\n <tr>\n <th style=\"text-align:right;\"> age </th>\n <th style=\"text-align:left;\"> sex </th>\n <th style=\"text-align:left;\"> class </th>\n <th style=\"text-align:left;\"> survived </th>\n </tr>\n </thead>\n<tbody>\n <tr>\n <td style=\"text-align:right;\"> 2 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 2 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 2 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 2 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 2 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 3 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 3 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 3 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 3 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 3 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 3 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 4 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 4 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 4 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 4 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n</tbody>\n</table>\n\n`````\n:::\n:::\n\n\n:::\n\n::: {.column width=\"30%\" .xtiny-font}\n\n\n::: {.cell}\n::: {.cell-output-display}\n`````{=html}\n<table>\n <thead>\n <tr>\n <th style=\"text-align:right;\"> age </th>\n <th style=\"text-align:left;\"> sex </th>\n <th style=\"text-align:left;\"> class </th>\n <th style=\"text-align:left;\"> survived </th>\n </tr>\n </thead>\n<tbody>\n <tr>\n <td style=\"text-align:right;\"> 4 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 1st </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 4 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 4 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 5 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 5 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 5 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 6 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 6 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 6 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 1st </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 6 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 6 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 3rd </td>\n <td style=\"text-align:left;\"> died </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 7 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 8 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 8 </td>\n <td style=\"text-align:left;\"> female </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n <tr>\n <td style=\"text-align:right;\"> 8 </td>\n <td style=\"text-align:left;\"> male </td>\n <td style=\"text-align:left;\"> 2nd </td>\n <td style=\"text-align:left;\"> survived </td>\n </tr>\n</tbody>\n</table>\n\n`````\n:::\n:::\n\n\n:::\n\n::::\n\n## Histogram: Define bins and count cases\n\n<br>\n\n\n\n::: {.cell}\n\n:::\n\n\n\n\n:::: {.columns}\n\n::: {.column width=\"25%\" .tiny-font}\n\n\n::: {.cell}\n::: {.cell-output-display}\n`````{=html}\n<table>\n <thead>\n <tr>\n <th style=\"text-align:left;\"> age range </th>\n <th style=\"text-align:right;\"> count </th>\n </tr>\n </thead>\n<tbody>\n <tr>\n <td style=\"text-align:left;\"> 0–4 </td>\n <td style=\"text-align:right;\"> 33 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 5–9 </td>\n <td style=\"text-align:right;\"> 20 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 10–14 </td>\n <td style=\"text-align:right;\"> 15 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 15–19 </td>\n <td style=\"text-align:right;\"> 81 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 20–24 </td>\n <td style=\"text-align:right;\"> 139 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 25–29 </td>\n <td style=\"text-align:right;\"> 113 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 30–34 </td>\n <td style=\"text-align:right;\"> 93 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 35–39 </td>\n <td style=\"text-align:right;\"> 75 </td>\n </tr>\n</tbody>\n</table>\n\n`````\n:::\n:::\n\n\n:::\n\n::: {.column width=\"25%\" .tiny-font}\n\n\n::: {.cell}\n::: {.cell-output-display}\n`````{=html}\n<table>\n <thead>\n <tr>\n <th style=\"text-align:left;\"> age range </th>\n <th style=\"text-align:right;\"> count </th>\n </tr>\n </thead>\n<tbody>\n <tr>\n <td style=\"text-align:left;\"> 40–44 </td>\n <td style=\"text-align:right;\"> 47 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 45–49 </td>\n <td style=\"text-align:right;\"> 59 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 50–54 </td>\n <td style=\"text-align:right;\"> 31 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 55–59 </td>\n <td style=\"text-align:right;\"> 23 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 60–64 </td>\n <td style=\"text-align:right;\"> 19 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 65–69 </td>\n <td style=\"text-align:right;\"> 4 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 70–74 </td>\n <td style=\"text-align:right;\"> 4 </td>\n </tr>\n <tr>\n <td style=\"text-align:left;\"> 75–79 </td>\n <td style=\"text-align:right;\"> 0 </td>\n </tr>\n</tbody>\n</table>\n\n`````\n:::\n:::\n\n\n:::\n\n::: {.column width=\"50%\"}\n\n\n::: {.cell}\n::: {.cell-output-display}\n![&nbsp;](visualizing-distributions-1_files/figure-revealjs/titanic-age-hist-1.svg){width=100%}\n:::\n:::\n\n\n:::\n\n::::\n\n## Histograms depend on the chosen bin width\n\n\n\n::: {.cell}\n::: {.cell-output-display}\n![&nbsp;](visualizing-distributions-1_files/figure-revealjs/titanic-age-hist-binwidth-1.svg){width=90%}\n:::\n:::\n\n\n\n\n<!-- Segment ends here -->\n\n## Further reading\n\n::: {.small-font}\n:::",
"supporting": [
"visualizing-distributions-1_files"
],
"filters": [
"rmarkdown/pagebreak.lua"
],
"includes": {
"include-after-body": [
"\n<script>\n // htmlwidgets need to know to resize themselves when slides are shown/hidden.\n // Fire the \"slideenter\" event (handled by htmlwidgets.js) when the current\n // slide changes (different for each slide format).\n (function () {\n // dispatch for htmlwidgets\n function fireSlideEnter() {\n const event = window.document.createEvent(\"Event\");\n event.initEvent(\"slideenter\", true, true);\n window.document.dispatchEvent(event);\n }\n\n function fireSlideChanged(previousSlide, currentSlide) {\n fireSlideEnter();\n\n // dispatch for shiny\n if (window.jQuery) {\n if (previousSlide) {\n window.jQuery(previousSlide).trigger(\"hidden\");\n }\n if (currentSlide) {\n window.jQuery(currentSlide).trigger(\"shown\");\n }\n }\n }\n\n // hookup for slidy\n if (window.w3c_slidy) {\n window.w3c_slidy.add_observer(function (slide_num) {\n // slide_num starts at position 1\n fireSlideChanged(null, w3c_slidy.slides[slide_num - 1]);\n });\n }\n\n })();\n</script>\n\n"
]
},
"engineDependencies": {},
"preserve": {},
"postProcess": true
}
}
Loading

0 comments on commit dbde4b2

Please sign in to comment.