Add missing alt text

This commit is contained in:
mine-cetinkaya-rundel 2023-05-26 15:11:02 -04:00
parent 9470637463
commit 597dec28da
1 changed files with 9 additions and 0 deletions

View File

@ -723,6 +723,11 @@ For example, if you might want to do a vertical bar chart where you automaticall
Since the bar chart is vertical, we also need to reverse the usual order to get the highest values at the top:
```{r}
#| fig-alt: |
#| Bar plot of clarify of diamonds, where clarity is on the y-axis and counts
#| are on the x-axis, and the bars are ordered in order of frequency: SI1,
#| VS2, SI2, VS1, VVS2, VVS1, IF, I1.
sorted_bars <- function(df, var) {
df |>
mutate({{ var }} := fct_rev(fct_infreq({{ var }}))) |>
@ -740,6 +745,10 @@ To work around this problem, we use the special operator `:=` which tidy evaluat
Or maybe you want to make it easy to draw a bar plot just for a subset of the data:
```{r}
#| fig-alt: |
#| Bar plot of clarity of diamonds. The most common is SI1, then SI2, then
#| VS2, then VS1, then VVS2, then VVS1, then I1, then lastly IF.
conditional_bars <- function(df, condition, var) {
df |>
filter({{ condition }}) |>