---
title: "SML201 Bar charts"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

### Bar charts summary

# `stat`

`stat` can be `"identity"` (we specify the value of the y manually, like in a scatterploy) or `"count"` (in which case the special values `..count..` and `..prop..` are computed and can be mapped to the y axis). `bin` is another option, but we use `geom_histogram` for that.

# `position`

`position` can be `"identity"`, in which case the bars are displayed according to the x value without modification (overlayed on each other as necessary), `"dodge"`, in which bars that would otherwise overlap are displayed side-by side ("dodging" each other), or `"stack"`, in which case bars with the same x value are stacked on top of each other. When using `position = "identity"` it often makes sense to specify `alpha = 0.5` (or something like that) to make the bars semi-transparent.

# `group`

See [Healy Ch. 4.4](https://socviz.co/groupfacettx.html)

### `geom_histogram`

`geom_histogram` is just `geom_bar` with `stat = "bin"`.  All the different `position` values discussed above can be used.