From 597dec28dac302d15eced72bbb59d138c31adc87 Mon Sep 17 00:00:00 2001 From: mine-cetinkaya-rundel Date: Fri, 26 May 2023 15:11:02 -0400 Subject: [PATCH] Add missing alt text --- functions.qmd | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/functions.qmd b/functions.qmd index df68593..d46a8cc 100644 --- a/functions.qmd +++ b/functions.qmd @@ -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 }}) |>