class: bottom, left, title-slide .title[ # Seamless data-driven reporting with {epoxy} ] .author[ ### Garrick Aden-Buie ] .date[ ### R/Medicine: 2023-06-08 ] --- background-size: cover background-position: bottom right background-image: url(images/tanaphong-toochinda-GagC07wVvck-unsplash.jpg) <STYLE type='text/css' scoped> PRE.fansi SPAN {padding-top: .25em; padding-bottom: .25em}; </STYLE> .footnote[ .bg-white-blur[Photo by <a href="https://unsplash.com/photos/GagC07wVvck">Tanaphong Toochinda</a>] ] ??? I recently learned an interesting fact about childcare costs in the U.S. in a report by the Department of Labor: --- layout: true name: quote .fancy-quote.f3.lh-copy.mt5[ A study of childcare prices in .hl.number[2,360] U.S. counties across .hl.number[47] states shows that childcare prices for a single child range from .hl.number[$4,810] .hl.qualifier[for school-age home-based care in small counties] to .hl.number[$15,417] .hl.qualifier[for infant center-based care in very large counties]. This is equivalent to between .hl.number[8%] and .hl.number[19.3%] of median family income per child in paid care. ] .footnote[ [National Database of Childcare Prices](https://www.dol.gov/newsroom/releases/wb/wb20230124) ] --- ??? \[read quote\] If you're anything like me, one part of you is saying "wow, children are expensive". (at least in the U.S.) The other part of you is thinking about the raw data behind this sentence. You're probably noticing the qualifiers... --- class: hl-qualifier ??? You're probably noticing the qualifiers in this quote, like [read qualifiers]. You're thinking about how these qualifiers map to decisions about how the data was summarized. And you're definitely thinking about all of the numbers in this quote... --- class: hl-number ??? ... like [read numbers] And now you're completely distracted thinking about the process behind this quote. * Where did the data come from? * How hard was it to clean? * How did it go from rows in a table to this sentence in the report? * I mean that literally, like, what happens if we find an error or a state updates a CSV file somewhere? Who's job is it to come back to this sentence and update it? --- layout: false background-image: url(images/la-rel-easter-KuCGlBXjH_o-unsplash.jpg) background-size: 115% background-position: bottom center .footnote.white[ Photo by <a href="https://unsplash.com/photos/KuCGlBXjH_o">La-Rel Easter</a> ] ??? When we talk about data-driven reporting, I think it's important to acknowledge how many decisions we pack into the tight spaces between our words. --- ```r childcare_summary ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 32 × 5</span> #> county_size type age cost mhi_pct #> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> #> <span style='color: #BCBCBC;'> 1</span> small center school-age <span style='text-decoration: underline;'>5</span>288. 0.109 #> <span style='color: #BCBCBC;'> 2</span> small home school-age <span style='text-decoration: underline;'>4</span>810 0.099<span style='text-decoration: underline;'>1</span> #> <span style='color: #BCBCBC;'> 3</span> small center infant <span style='text-decoration: underline;'>7</span>461. 0.154 #> <span style='color: #BCBCBC;'> 4</span> small center toddler <span style='text-decoration: underline;'>6</span>760 0.139 #> <span style='color: #BCBCBC;'> 5</span> small center preschool <span style='text-decoration: underline;'>6</span>239. 0.129 #> <span style='color: #BCBCBC;'> 6</span> small home infant <span style='text-decoration: underline;'>5</span>824 0.120 #> <span style='color: #BCBCBC;'> 7</span> small home toddler <span style='text-decoration: underline;'>5</span>713. 0.118 #> <span style='color: #BCBCBC;'> 8</span> small home preschool <span style='text-decoration: underline;'>5</span>541. 0.114 #> <span style='color: #BCBCBC;'> 9</span> mid-sized center school-age <span style='text-decoration: underline;'>6</span>732. 0.115 #> <span style='color: #BCBCBC;'>10</span> mid-sized home school-age <span style='text-decoration: underline;'>6</span>360. 0.108 #> <span style='color: #949494;'># ℹ 22 more rows</span> </CODE></PRE> ??? All of these descisions manifest in a data frame or two. And it's extra satisfying when they're tidy. This table plugs in very nicely into dense tables and plots, which we're as data scientists lean on heavily. --- background-image: url('images/map-plot.png') background-size: 85% background-position: bottom center .clip[ Slide image: a map of the U.S. with each county shaded by median yearly price of infant center-based care. Chester County, PA is highlighted and an pop-over lists related statistics about the county. ] .footnote[ .f6[[Women's Bureau](https://www.dol.gov/agencies/wb/topics/childcare/price-by-age-care-setting)] ] ??? Like this map of the U.S. comparing the median yearly price of infant center-based care. This map is great (and it's even interactive!) but it has its place. No reasonable person is going to use this map and arrive at the conclusions of our quote. --- <img src="index_files/figure-html/plot-basic-1.png" width="100%" /> ??? Or this super basic horizontal bar plot. I just took the table and passed it to ggplot, mapping childcare costs to the x-axis and the child's age group to the y-axis. I faceted by county size and I set the bar color to the type of care: home-based or center-based care. --- ```r ggplot(childcare_summary) + aes(cost, age, fill = type) + geom_col(position = "dodge") + facet_wrap(~ county_size) + theme_grey(14) ``` ??? This only takes a few lines of code. But ggplot also gives you all kinds of tools to help you take the raw data and map it to labels and text that's easier to understand. --- ```r ggplot(childcare_summary) + aes(cost, age, fill = type) + geom_col(position = "dodge") + facet_wrap( ~ county_size, labeller = labeller(county_size = \(x) str_to_title(paste(x, "County"))) ) + labs( x = "Median yearly cost", y = "Age group", fill = "Type of care" ) + scale_fill_discrete(labels = \(x) paste0(x, "-based")) + scale_x_continuous( labels = scales::dollar_format(scale_cut = scales::cut_short_scale()) ) + theme_gray(14) ``` ??? With a few more lines of code --- ```r ggplot(childcare_summary) + aes(cost, age, fill = type) + geom_col(position = "dodge") + facet_wrap( ~ county_size, labeller = labeller(county_size = \(x) str_to_title(paste(x, "County"))) ) + * labs( * x = "Median yearly cost", * y = "Age group", * fill = "Type of care" * ) + scale_fill_discrete(labels = \(x) paste0(x, "-based")) + scale_x_continuous( labels = scales::dollar_format(scale_cut = scales::cut_short_scale()) ) + theme_gray(14) ``` ??? we can give the axis and legend appropriate labels --- ```r ggplot(childcare_summary) + aes(cost, age, fill = type) + geom_col(position = "dodge") + facet_wrap( ~ county_size, labeller = labeller(county_size = \(x) str_to_title(paste(x, "County"))) ) + labs( x = "Median yearly cost", y = "Age group", fill = "Type of care" ) + scale_fill_discrete(labels = \(x) paste0(x, "-based")) + * scale_x_continuous( * labels = scales::dollar_format(scale_cut = scales::cut_short_scale()) * ) + theme_gray(14) ``` ??? And we can format the x-axis in U.S. dollars --- ```r ggplot(childcare_summary) + aes(cost, age, fill = type) + geom_col(position = "dodge") + facet_wrap( ~ county_size, * labeller = labeller(county_size = \(x) str_to_title(paste(x, "County"))) ) + labs( x = "Median yearly cost", y = "Age group", fill = "Type of care" ) + * scale_fill_discrete(labels = \(x) paste0(x, "-based")) + scale_x_continuous( labels = scales::dollar_format(scale_cut = scales::cut_short_scale()) ) + theme_gray(14) ``` ??? or give the facets and legends better labels To end up with a plot like this... --- <img src="index_files/figure-html/plot-fancy-1.png" width="100%" /> ??? But these updates all happen between our data frame and the last few lines of code. --- ```r childcare_summary ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 32 × 5</span> #> county_size type age cost mhi_pct #> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> #> <span style='color: #BCBCBC;'> 1</span> small center school-age <span style='text-decoration: underline;'>5</span>288. 0.109 #> <span style='color: #BCBCBC;'> 2</span> small home school-age <span style='text-decoration: underline;'>4</span>810 0.099<span style='text-decoration: underline;'>1</span> #> <span style='color: #BCBCBC;'> 3</span> small center infant <span style='text-decoration: underline;'>7</span>461. 0.154 #> <span style='color: #BCBCBC;'> 4</span> small center toddler <span style='text-decoration: underline;'>6</span>760 0.139 #> <span style='color: #BCBCBC;'> 5</span> small center preschool <span style='text-decoration: underline;'>6</span>239. 0.129 #> <span style='color: #BCBCBC;'> 6</span> small home infant <span style='text-decoration: underline;'>5</span>824 0.120 #> <span style='color: #BCBCBC;'> 7</span> small home toddler <span style='text-decoration: underline;'>5</span>713. 0.118 #> <span style='color: #BCBCBC;'> 8</span> small home preschool <span style='text-decoration: underline;'>5</span>541. 0.114 #> <span style='color: #BCBCBC;'> 9</span> mid-sized center school-age <span style='text-decoration: underline;'>6</span>732. 0.115 #> <span style='color: #BCBCBC;'>10</span> mid-sized home school-age <span style='text-decoration: underline;'>6</span>360. 0.108 #> <span style='color: #949494;'># ℹ 22 more rows</span> </CODE></PRE> ??? Meaning that we didn't have to change our source data frame at all. --- class: middle f1 highlight-last-item <h2 class="f1" style="font-size:3rem">epoxy</h2> * .f3[Handle .pink.b[last-mile] transformations] ??? I started working on epoxy because I wanted better tools that help you make these kinds of last-mile transformations easier. -- * .f3[Seamlessly use data in .pink.b[the prose] of reports and apps] ??? Tools that make it seamless to blend data into prose -- * .f3[Re-usability through .pink.b[templates] and global settings] ??? And that improve usability through templates and global settings --- class: middle center animated slideInDown slideOutDown .center.w-50[ ![glue hex sticker](images/glue.svg) ] ??? The good news is that there's an awesome package called glue that does most of what I wanted but for strings in R. It's biggest limitation is that it's a developer-oriented package, meaning that it's designed to do one thing well with a minimal API and basically zero dependencies. --- class: middle center animated slideInDown .center.w-50[ ![epoxy hex sticker](images/epoxy.svg) ] ??? So you could consider epoxy an extension package for glue, which also explains the name and the hex sticker. --- class: middle .f2.code[ install.packages(.pink["epoxy"]) <br /> .silver[pak::pak("gadenbuie/epoxy")] <br /> <br /> library(.pink[epoxy]) <br /> .silver[library(glue)] ] ??? You can install epoxy from CRAN and load it in the usual ways. I'm loading glue here too for later in the presentation, but you don't need to do that to use epoxy. --- class: inverse center middle # Let's try this together .f3.f-zilla.dib.animated.lightSpeedIn.delay-1s[(speed run)] --- layout: true ## TidyTuesday (2023, Week 19) --- ```r library(tidyverse) tuesdata <- tidytuesdayR::tt_load(2023, week = 19) childcare_costs <- tuesdata$childcare_costs counties <- tuesdata$counties ``` ??? First of all, huge thanks to the TidyTuesday project where I discovered this dataset. They also make it super easy to download the dataset and start working with it. --- ```r counties ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 3,144 × 4</span> #> county_fips_code county_name state_name state_abbreviation #> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><chr></span> #> <span style='color: #BCBCBC;'> 1</span> <span style='text-decoration: underline;'>1</span>001 Autauga County Alabama AL #> <span style='color: #BCBCBC;'> 2</span> <span style='text-decoration: underline;'>1</span>003 Baldwin County Alabama AL #> <span style='color: #BCBCBC;'> 3</span> <span style='text-decoration: underline;'>1</span>005 Barbour County Alabama AL #> <span style='color: #BCBCBC;'> 4</span> <span style='text-decoration: underline;'>1</span>007 Bibb County Alabama AL #> <span style='color: #BCBCBC;'> 5</span> <span style='text-decoration: underline;'>1</span>009 Blount County Alabama AL #> <span style='color: #BCBCBC;'> 6</span> <span style='text-decoration: underline;'>1</span>011 Bullock County Alabama AL #> <span style='color: #BCBCBC;'> 7</span> <span style='text-decoration: underline;'>1</span>013 Butler County Alabama AL #> <span style='color: #BCBCBC;'> 8</span> <span style='text-decoration: underline;'>1</span>015 Calhoun County Alabama AL #> <span style='color: #BCBCBC;'> 9</span> <span style='text-decoration: underline;'>1</span>017 Chambers County Alabama AL #> <span style='color: #BCBCBC;'>10</span> <span style='text-decoration: underline;'>1</span>019 Cherokee County Alabama AL #> <span style='color: #949494;'># ℹ 3,134 more rows</span> </CODE></PRE> ??? The data come with two data sets (which were originally one set). Counties and states... --- ```r childcare_costs ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 34,567 × 61</span> #> county_fips_code study_year unr_16 funr_16 munr_16 unr_20to64 funr_20to64 #> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> #> <span style='color: #BCBCBC;'> 1</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>008 5.42 4.41 6.32 4.6 3.5 #> <span style='color: #BCBCBC;'> 2</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>009 5.93 5.72 6.11 4.8 4.6 #> <span style='color: #BCBCBC;'> 3</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>010 6.21 5.57 6.78 5.1 4.6 #> <span style='color: #BCBCBC;'> 4</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>011 7.55 8.13 7.03 6.2 6.3 #> <span style='color: #BCBCBC;'> 5</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>012 8.6 8.88 8.29 6.7 6.4 #> <span style='color: #BCBCBC;'> 6</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>013 9.39 10.3 8.56 7.3 7.6 #> <span style='color: #BCBCBC;'> 7</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>014 8.5 9.18 7.95 6.8 6.8 #> <span style='color: #BCBCBC;'> 8</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>015 7.64 8.45 6.91 5.9 6.1 #> <span style='color: #BCBCBC;'> 9</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>016 5.59 6.27 4.99 4.4 4.6 #> <span style='color: #BCBCBC;'>10</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>017 5.21 5.84 4.64 4.6 4.9 #> <span style='color: #949494;'># ℹ 34,557 more rows</span> #> <span style='color: #949494;'># ℹ 54 more variables: munr_20to64 <dbl>, flfpr_20to64 <dbl>,</span> #> <span style='color: #949494;'># flfpr_20to64_under6 <dbl>, flfpr_20to64_6to17 <dbl>,</span> #> <span style='color: #949494;'># flfpr_20to64_under6_6to17 <dbl>, mlfpr_20to64 <dbl>, pr_f <dbl>,</span> #> <span style='color: #949494;'># pr_p <dbl>, mhi_2018 <dbl>, me_2018 <dbl>, fme_2018 <dbl>, mme_2018 <dbl>,</span> #> <span style='color: #949494;'># total_pop <dbl>, one_race <dbl>, one_race_w <dbl>, one_race_b <dbl>,</span> #> <span style='color: #949494;'># one_race_i <dbl>, one_race_a <dbl>, one_race_h <dbl>, …</span> </CODE></PRE> ??? And the main attraction, the child care costs. --- layout: false ## Data Dictionary: `childcare_costs` <img src="images/data-dictionary1.png" alt="A screenshot of a long table with descriptions for each of the 61 columns in the childcare_costs dataset." style="width:32%;"> <img src="images/data-dictionary2.png" alt="" style="width:32%;"> <img src="images/data-dictionary3.png" alt="" style="width:32%;"> --- .flex[ .w-25[ ## Prepare * 2018 only * Where reported * Pick: population, income, price * County size ] .w-75.pl2[ ```r childcare_summary <- childcare_costs |> filter(study_year == 2018, !is.na(mc_infant)) |> select(1:2, total_pop, mhi_2018, matches("mfcc|mc")) |> mutate( county_size = case_when( total_pop < 1e5 ~ "small", total_pop < 5e5 ~ "mid-sized", total_pop < 1e6 ~ "large", TRUE ~ "very large" ), county_size = fct_reorder(county_size, total_pop) ) ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 2,360 × 13</span> #> county_fips_code study_year total_pop mhi_2018 mcsa #> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> #> <span style='color: #BCBCBC;'>1</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>018 <span style='text-decoration: underline;'>55</span>200 <span style='text-decoration: underline;'>58</span>786 95.9 #> <span style='color: #BCBCBC;'>2</span> <span style='text-decoration: underline;'>1</span>003 <span style='text-decoration: underline;'>2</span>018 <span style='text-decoration: underline;'>208</span>107 <span style='text-decoration: underline;'>55</span>962 108. #> <span style='color: #BCBCBC;'>3</span> <span style='text-decoration: underline;'>1</span>005 <span style='text-decoration: underline;'>2</span>018 <span style='text-decoration: underline;'>25</span>782 <span style='text-decoration: underline;'>34</span>186 79.2 #> <span style='color: #BCBCBC;'>4</span> <span style='text-decoration: underline;'>1</span>007 <span style='text-decoration: underline;'>2</span>018 <span style='text-decoration: underline;'>22</span>527 <span style='text-decoration: underline;'>45</span>340 102. #> <span style='color: #BCBCBC;'>5</span> <span style='text-decoration: underline;'>1</span>009 <span style='text-decoration: underline;'>2</span>018 <span style='text-decoration: underline;'>57</span>645 <span style='text-decoration: underline;'>48</span>695 127. #> <span style='color: #949494;'># ℹ 2,355 more rows</span> #> <span style='color: #949494;'># ℹ 8 more variables: mfccsa <dbl>, mc_infant <dbl>,</span> #> <span style='color: #949494;'># mc_toddler <dbl>, mc_preschool <dbl>,</span> #> <span style='color: #949494;'># mfcc_infant <dbl>, mfcc_toddler <dbl>,</span> #> <span style='color: #949494;'># mfcc_preschool <dbl>, county_size <fct></span> </CODE></PRE> ] ] --- .flex[ .w-25[ ## Pivot * Collect all costs * Extract information from variable names * Recode age and type * Convert to yearly cost ] .w-75.pl2[ ```r childcare_summary <- childcare_summary |> pivot_longer( cols = matches("mfcc|mc"), names_to = c("type", "age"), names_pattern = "(mfcc|mc)(.*)", values_to = "cost" ) |> mutate( age = str_remove(age, "^_"), age = recode(age, sa = "school-age"), age = factor(age, c("infant", "toddler", "preschool", "school-age")), type = recode(type, mfcc = "home", mc = "center"), cost = cost * 52 ) ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 18,880 × 8</span> #> county_fips_code study_year total_pop mhi_2018 county_size #> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><fct></span> #> <span style='color: #BCBCBC;'>1</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>018 <span style='text-decoration: underline;'>55</span>200 <span style='text-decoration: underline;'>58</span>786 small #> <span style='color: #BCBCBC;'>2</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>018 <span style='text-decoration: underline;'>55</span>200 <span style='text-decoration: underline;'>58</span>786 small #> <span style='color: #BCBCBC;'>3</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>018 <span style='text-decoration: underline;'>55</span>200 <span style='text-decoration: underline;'>58</span>786 small #> <span style='color: #BCBCBC;'>4</span> <span style='text-decoration: underline;'>1</span>001 <span style='text-decoration: underline;'>2</span>018 <span style='text-decoration: underline;'>55</span>200 <span style='text-decoration: underline;'>58</span>786 small #> <span style='color: #949494;'># ℹ 18,876 more rows</span> #> <span style='color: #949494;'># ℹ 3 more variables: type <chr>, age <fct>, cost <dbl></span> </CODE></PRE> ] ] --- .flex[ .w-25[ ## Summarize * Median cost and income * By county size, care type and age group * Cost as a % of income ] .w-75.pl2[ ```r childcare_summary <- childcare_summary |> summarize( across(cost, \(x) median(x, na.rm = TRUE)), across(mhi_2018, \(x) median(x, na.rm = TRUE)), .by = c(county_size, type, age) ) |> mutate(mhi_pct = cost / mhi_2018) |> select(-mhi_2018) ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 32 × 5</span> #> county_size type age cost mhi_pct #> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> #> <span style='color: #BCBCBC;'> 1</span> small center school-age <span style='text-decoration: underline;'>5</span>288. 0.109 #> <span style='color: #BCBCBC;'> 2</span> small home school-age <span style='text-decoration: underline;'>4</span>810 0.099<span style='text-decoration: underline;'>1</span> #> <span style='color: #BCBCBC;'> 3</span> small center infant <span style='text-decoration: underline;'>7</span>461. 0.154 #> <span style='color: #BCBCBC;'> 4</span> small center toddler <span style='text-decoration: underline;'>6</span>760 0.139 #> <span style='color: #BCBCBC;'> 5</span> small center preschool <span style='text-decoration: underline;'>6</span>239. 0.129 #> <span style='color: #BCBCBC;'> 6</span> small home infant <span style='text-decoration: underline;'>5</span>824 0.120 #> <span style='color: #BCBCBC;'> 7</span> small home toddler <span style='text-decoration: underline;'>5</span>713. 0.118 #> <span style='color: #BCBCBC;'> 8</span> small home preschool <span style='text-decoration: underline;'>5</span>541. 0.114 #> <span style='color: #BCBCBC;'> 9</span> mid-sized center school-age <span style='text-decoration: underline;'>6</span>732. 0.115 #> <span style='color: #BCBCBC;'>10</span> mid-sized home school-age <span style='text-decoration: underline;'>6</span>360. 0.108 #> <span style='color: #949494;'># ℹ 22 more rows</span> </CODE></PRE> ] ] --- .flex[ .w-25[ ## Quote * Min/max cost ] .w-75.pl2[ ```r costs_min <- childcare_summary |> filter(mhi_pct == min(mhi_pct)) ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 1 × 5</span> #> county_size type age cost mhi_pct #> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> #> <span style='color: #BCBCBC;'>1</span> small home school-age <span style='text-decoration: underline;'>4</span>810 0.099<span style='text-decoration: underline;'>1</span> </CODE></PRE> ```r costs_max <- childcare_summary |> filter(mhi_pct == max(mhi_pct)) ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 1 × 5</span> #> county_size type age cost mhi_pct #> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> #> <span style='color: #BCBCBC;'>1</span> very large center infant <span style='text-decoration: underline;'>15</span>417. 0.238 </CODE></PRE> ] ] --- .flex[ .w-25[ ## Quote * Also counts of counties and states ] .w-75.pl2[ ```r counties_states <- childcare_costs |> filter(study_year == 2018, !is.na(mc_infant)) |> left_join(counties, by = "county_fips_code") |> distinct(state_abbreviation, county_name) n_counties <- nrow(counties_states) ``` ``` #> [1] 2360 ``` ```r n_states <- n_distinct(counties_states$state_abbreviation) ``` ``` #> [1] 41 ``` ] ] --- class: inverse center middle # How do we get this into prose? --- ```r costs_min ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 1 × 5</span> #> county_size type age cost mhi_pct #> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> #> <span style='color: #BCBCBC;'>1</span> small home school-age <span style='text-decoration: underline;'>4</span>810 0.099<span style='text-decoration: underline;'>1</span> </CODE></PRE> ```r costs_max ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 1 × 5</span> #> county_size type age cost mhi_pct #> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><fct></span> <span style='color: #949494; font-style: italic;'><dbl></span> <span style='color: #949494; font-style: italic;'><dbl></span> #> <span style='color: #BCBCBC;'>1</span> very large center infant <span style='text-decoration: underline;'>15</span>417. 0.238 </CODE></PRE> --- layout: true ## R Markdown is amazing --- ```markdown A study of childcare prices in 2,360 U.S. counties across 47 states shows that childcare prices for a single child range from $4,810 for school-age home-based care in small counties to $15,417 for infant center-based care in very large counties. This is equivalent to between 8% and 19.3% of median family income per child in paid care. ``` ??? Here's our sentence as if we've written it out in an `.Rmd` file. I've broken it up into a lot of lines so that the changes are easier to read as we modify this. --- ```markdown A study of childcare prices in ____ U.S. counties across ____ states shows that childcare prices for a single child range from $____ for school-age home-based care in small counties to $____ for infant center-based care in very large counties. This is equivalent to between ____% and ____% of median family income per child in paid care. ``` ??? But when we're coming up with a sentence like this, we don't know what the numbers are going to be. So let's replace these with blanks. --- ```markdown A study of childcare prices in ____ U.S. counties across ____ states shows that childcare prices for a single child range from $____ for school-age home-based care in ____ counties to $____ for infant center-based care in ____ counties. This is equivalent to between ____% and ____% of median family income per child in paid care. ``` ??? We also don't know which county sizes we're going to be talking about. --- ```markdown A study of childcare prices in ____ U.S. counties across ____ states shows that childcare prices for a single child range from $____ for school-age ____-based care in ____ counties to $____ for infant ____-based care in ____ counties. This is equivalent to between ____% and ____% of median family income per child in paid care. ``` ??? Or the type of childcare or educational center --- ```markdown A study of childcare prices in ____ U.S. counties across ____ states shows that childcare prices for a single child range from $____ for ____ ____-based care in ____ counties to $____ for ____ ____-based care in ____ counties. This is equivalent to between ____% and ____% of median family income per child in paid care. ``` ??? Or even which age group will be involved in the least and most expensive categories. --- ```markdown A study of childcare prices in *`r n_counties` U.S. counties across *`r n_states` states shows that childcare prices for a single child range from *$____ *for ____ ____-based care *in ____ counties to *$____ *for ____ ____-based care *in ____ counties. This is equivalent to between *____% and ____% of median family income per child in paid care. ``` ??? And then we work our way forward, using inline code chunks to blend our data into the text. --- ```markdown A study of childcare prices in *`r n_counties` U.S. counties across *`r n_states` states shows that childcare prices for a single child range from *`r costs_min$cost` *for `r costs_min$age` `r costs_min$type`-based care *in `r costs_min$county_size` counties to *$____ *for ____ ____-based care *in ____ counties. This is equivalent to between *`r costs_min$mhi_pct` and ____% of median family income per child in paid care. ``` ??? Then all the pieces we know from the minimum cost category --- ```markdown A study of childcare prices in *`r n_counties` U.S. counties across *`r n_states` states shows that childcare prices for a single child range from *`r costs_min$cost` *for `r costs_min$age` `r costs_min$type`-based care *in `r costs_min$county_size` counties to *`r costs_max$cost` *for `r costs_max$age` `r costs_max$type`-based care *in `r costs_max$county_size` counties. This is equivalent to between *`r costs_min$mhi_pct` and `r costs_max$mhi_pct` of median family income per child in paid care. ``` ??? and everything we know from the maximum cost category --- layout: true ## R Markdown is amazing.pink[-ish] --- A study of childcare prices in <br/> 2360 <br/> U.S. counties across <br/> 41 <br/> states shows that childcare prices <br/> for a single child <br/> range from <br/> 4810 <br/> for school-age home-based care <br/> in small counties to <br/> 1.541696\times 10^{4} <br/> for infant center-based care <br/> in very large counties. <br/> This is equivalent to between <br/> 0.0990792 and 0.2376447 <br/> of median family income per child in paid care. ??? And then we render it... and it's amazing. I mean, it's fine. It's great that we're not copying and pasting numbers into our documents! But this isn't quite right. --- ```markdown A study of childcare prices in *`r format(n_counties, big.mark = ",")` U.S. counties across *`r format(n_states, big.mark = ",")` states shows that childcare prices for a single child range from *$`r format(costs_min$cost, big.mark = ",")` *for `r costs_min$age` `r costs_min$type`-based care *in `r costs_min$county_size` counties *$`r format(round(costs_max$cost, 0), big.mark = ",")` *for `r costs_max$age` `r costs_max$type`-based care *in `r costs_max$county_size` counties. This is equivalent to between *`r round(costs_min$mhi_pct * 100, 2)`% and `r round(costs_max$mhi_pct * 100, 2)`% of median family income per child in paid care. ``` ??? But these are inline code chunks, right, so we can just write some code around the values. --- layout: true class: center middle ## Spicy hot-take time --- --- .f2.absolute.center.left-0.w-100[ .animated.fadeInDownBig.dib.delay-staggered[🌶️] .animated.fadeInDownBig.dib.delay-staggered[.o-30[🌶️]] .animated.fadeInDownBig.dib.delay-staggered[.o-30[🌶️]] .animated.fadeInDownBig.dib.delay-staggered[.o-30[🌶️]] .animated.fadeInDownBig.dib.delay-staggered[.o-30[🌶️]] ] --- .f2.absolute.center.left-0.w-100.f-pen.animated.slideInLeft[ Write R code where it can be R code. ] --- layout: false class: middle ### .red[Bad] ```markdown prices range from $`r format(round(costs_max$cost, 0), big.mark = ",")` ``` -- ### .silver[Better] ````markdown ```{r} costs_max$cost <- format(round(costs_max$cost, 0), big.mark = ",") ``` prices range from $`r costs_max$cost` ```` -- ### .green[Better-er] ````markdown ```{r} costs_max$cost <- scales::dollar(costs_max$cost, accuracy = 1) ``` prices range from `r costs_max$cost` ```` --- class: center middle <img src="images/code-screenshot.png" width="100%" alt="A screenshot of code where the first line uses an inline R chunk and has no color or IDE hints, and the following line uses an R chunk and receives syntax highlighting and IDE assistance."> -- .f3.absolute.center.left-0.w-100.f-pen.animated.slideInLeft[ Inline code is for the simplist code you cannot possibly mess up. ] --- layout: true class: animated fadeIn ## R Markdown .pink[+ epoxy] --- ```markdown A study of childcare prices in `r n_counties` U.S. counties across `r n_states` states shows that childcare prices for a single child range from `r costs_min$cost` for `r costs_min$age` `r costs_min$type`-based care in `r costs_min$county_size` counties to `r costs_max$cost` for `r costs_max$age` `r costs_max$type`-based care in `r costs_max$county_size` counties. This is equivalent to between `r costs_min$mhi_pct` and `r costs_max$mhi_pct` of median family income per child in paid care. ``` --- ````markdown *```{r} *library(epoxy) *``` A study of childcare prices in `r n_counties` U.S. counties across `r n_states` states shows that childcare prices for a single child range from `r costs_min$cost` for `r costs_min$age` `r costs_min$type`-based care in `r costs_min$county_size` counties to `r costs_max$cost` for `r costs_max$age` `r costs_max$type`-based care in `r costs_max$county_size` counties. This is equivalent to between `r costs_min$mhi_pct` and `r costs_max$mhi_pct` of median family income per child in paid care. ```` --- ````markdown ```{r} library(epoxy) ``` *```{epoxy} A study of childcare prices in `r n_counties` U.S. counties across `r n_states` states shows that childcare prices for a single child range from `r costs_min$cost` for `r costs_min$age` `r costs_min$type`-based care in `r costs_min$county_size` counties to `r costs_max$cost` for `r costs_max$age` `r costs_max$type`-based care in `r costs_max$county_size` counties. This is equivalent to between `r costs_min$mhi_pct` and `r costs_max$mhi_pct` of median family income per child in paid care. *``` ```` --- ````markdown ```{r} library(epoxy) ``` ```{epoxy} A study of childcare prices in *`r n_counties` U.S. counties across *`r n_states` states shows that childcare prices for a single child range from *`r costs_min$cost` *for `r costs_min$age` `r costs_min$type`-based care *in `r costs_min$county_size` counties to *`r costs_max$cost` *for `r costs_max$age` `r costs_max$type`-based care *in `r costs_max$county_size` counties. This is equivalent to between *`r costs_min$mhi_pct` and `r costs_max$mhi_pct` of median family income per child in paid care. ``` ```` --- ````markdown ```{r} library(epoxy) ``` ```{epoxy} A study of childcare prices in *{n_counties} U.S. counties across *{n_states} states shows that childcare prices for a single child range from *{costs_min$cost} *for {costs_min$age} {costs_min$type}-based care *in {costs_min$county_size} counties to *{costs_max$cost} *for {costs_max$age} {costs_max$type}-based care *in {costs_max$county_size} counties. This is equivalent to between *{costs_min$mhi_pct} and {costs_max$mhi_pct} of median family income per child in paid care. ``` ```` --- ````markdown ```{r} library(epoxy) ``` ```{epoxy} A study of childcare prices in {n_counties} U.S. counties across {n_states} states shows that childcare prices for a single child range from {costs_min$cost} for {costs_min$age} {costs_min$type}-based care in {costs_min$county_size} counties to {costs_max$cost} for {costs_max$age} {costs_max$type}-based care in {costs_max$county_size} counties. This is equivalent to between {costs_min$mhi_pct} and {costs_max$mhi_pct} of median family income per child in paid care. ``` ```` --- layout: false class: center middle <video controls loop playsinline width="100%"> <source src="images/epoxy-autocomplete.mov" type="video/mp4"> </video> --- layout: false ## R Markdown .pink[+ epoxy] is amazing.pink.animated.dib.rotateInDownLeft.delay-2s[-ish] A study of childcare prices in <br/> 2360 <br/> U.S. counties across <br/> 41 <br/> states shows that childcare prices <br/> for a single child <br/> range from <br/> 4810 <br/> for school-age home-based care <br/> in small counties to <br/> 15416.96 <br/> for infant center-based care <br/> in very large counties. <br/> This is equivalent to between <br/> 0.0990792427956413 and 0.237644665043006 <br/> of median family income per child in paid care. --- layout: true class: center middle --- .code.f1[ `r costs_max$.primary[cost]` ] --- .code.f1[ {costs_max$.primary[cost]} ] --- .code.f1[ {.pink[.dollar] costs_max$.primary[cost]} ] --- .code.f1[ {.pink[.pct] costs_max$.primary[mhi_pct]} ] --- .code.f1[ {.pink[.comma] .primary[n_counties]} ] -- .code.f3[ scales::label_.pink[comma]()(.primary[n_counties]) ] --- layout: true class: animated fadeIn ## R Markdown .pink[+ epoxy] is amazing.pink.animated.dib.jackInTheBox[-er] --- ````markdown ```{r include=FALSE} library(epoxy) ``` ```{epoxy} A study of childcare prices in {.comma n_counties} U.S. counties across {n_states} states shows that childcare prices for a single child range from {.dollar costs_min$cost} for {costs_min$age} {costs_min$type}-based care in {costs_min$county_size} counties to {.dollar costs_max$cost} for {costs_max$age} {costs_max$type}-based care in {costs_max$county_size} counties. This is equivalent to between {.pct costs_min$mhi_pct} and {.pct costs_max$mhi_pct} of median family income per child in paid care. ``` ```` --- A study of childcare prices in 2,360 U.S. counties across 41 states shows that childcare prices for a single child range from $4,810 for school-age home-based care in small counties to $15,416.96 for infant center-based care in very large counties. This is equivalent to between 10% and 24% of median family income per child in paid care. --- layout: true ## .pink[epoxy] is built on .orange[glue] --- ```r glue("for a single child range from {costs_min$cost}") ``` ``` #> for a single child range from 4810 ``` -- ```r epoxy("for a single child range from {costs_min$cost}") ``` ``` #> for a single child range from 4810 ``` --- ```r glue("for a single child range from {.dollar costs_min$cost}") ``` ``` #> Error in parse(text = text, keep.source = FALSE): <text>:1:9: unexpected symbol #> 1: .dollar costs_min #> ^ ``` ```r epoxy("for a single child range from {.dollar costs_min$cost}") ``` ``` #> for a single child range from $4,810 ``` --- layout: false ## These are the same .mt3[ ### .Rmd ````markdown ```{epoxy} for a single child range from {.dollar costs_min$cost} ``` ```` for a single child range from $4,810 ] .mt4[ ### .R ```r epoxy("for a single child range from {.dollar costs_min$cost}") ``` ``` #> for a single child range from $4,810 ``` ] --- layout: true ## Inline transformations with epoxy --- ```r epoxy( "range from {.dollar costs_min$cost} to {.dollar costs_max$cost}" ) ``` ``` #> range from $4,810 to $15,416.96 ``` --- ```r epoxy( "range from {.dollar costs_min$cost} to {.dollar costs_max$cost}", .transformer = epoxy_transform_inline() ) ``` ``` #> range from $4,810 to $15,416.96 ``` --- ```r epoxy( "range from {.dollar costs_min$cost} to {.dollar costs_max$cost}", .transformer = epoxy_transform_inline( .dollar = scales::label_dollar() ) ) ``` ``` #> range from $4,810 to $15,416.96 ``` --- ```r epoxy( "range from {.dollar costs_min$cost} to {.dollar costs_max$cost}", .transformer = epoxy_transform_inline( .dollar = scales::label_dollar(accuracy = 10) ) ) ``` ``` #> range from $4,810 to $15,420 ``` --- ```r epoxy_transform_set( .dollar = scales::label_dollar(accuracy = 10) ) epoxy( "range from {.dollar costs_min$cost} to {.dollar costs_max$cost}" ) ``` ``` #> range from $4,810 to $15,420 ``` --- layout: true ## Inline transformations with epoxy ```r ages <- childcare_summary |> count(age) |> mutate(across(age, paste)) ``` <PRE class="fansi fansi-output"><CODE>#> <span style='color: #949494;'># A tibble: 4 × 2</span> #> age n #> <span style='color: #949494; font-style: italic;'><chr></span> <span style='color: #949494; font-style: italic;'><int></span> #> <span style='color: #BCBCBC;'>1</span> infant 8 #> <span style='color: #BCBCBC;'>2</span> toddler 8 #> <span style='color: #BCBCBC;'>3</span> preschool 8 #> <span style='color: #BCBCBC;'>4</span> school-age 8 </CODE></PRE> --- ```r epoxy("children were in the age groups {ages$age}") ``` ``` #> children were in the age groups infant #> children were in the age groups toddler #> children were in the age groups preschool #> children were in the age groups school-age ``` --- ```r epoxy("children were in the age groups {.and ages$age}") ``` ``` #> children were in the age groups infant, toddler, preschool, and school-age ``` --- ```r epoxy("children were in the age groups {.or ages$age}") ``` ``` #> children were in the age groups infant, toddler, preschool, or school-age ``` --- layout: true ## Inline transformations with epoxy --- ```r epoxy("age groups ranged from {.to ages$age}") ``` ``` #> age groups ranged from infant #> age groups ranged from toddler #> age groups ranged from preschool #> age groups ranged from school-age ``` --- ```r epoxy_transform_set( .to = function(x) { glue_collapse(x, sep = ", ", last = " to ") } ) epoxy("age groups ranged from {.to ages$age}") ``` ``` #> age groups ranged from infant, toddler, preschool to school-age ``` --- ```r epoxy("age groups ranged from {.to {.titlecase ages$age}}") ``` ``` #> age groups ranged from Infant, Toddler, Preschool to School-Age ``` --- ```r epoxy("age groups ranged from {.to {.tc ages$age}}") ``` ``` #> age groups ranged from Infant, Toddler, Preschool to School-Age ``` --- ```r epoxy( "These slides were rendered on {.date now()} at {.time now()}." ) ``` ``` #> These slides were rendered on 2023-06-08 at 14:43:05. ``` .footnote.o-80[ `now()` is from `lubridate`, which is now loaded with `library(tidyverse)`! ] --- ```r epoxy( "These slides were rendered on {.date now()} at {.time now()}.", .transformer = c("inline", "bold") ) ``` ``` #> These slides were rendered on **2023-06-08** at **14:43:05**. ``` --- layout: true ## epoxy for .pink[LaTeX] --- ```r epoxy("prices in {.comma n_counties} U.S. counties") ``` ``` #> prices in 2,360 U.S. counties ``` -- ```r epoxy("prices in {{.comma n_counties}} U.S. counties") ``` ``` #> prices in {.comma n_counties} U.S. counties ``` --- ```r epoxy("prices in \\textbf{{.comma n_counties}} U.S. counties") ``` ``` #> prices in \textbf{.comma n_counties} U.S. counties ``` -- ```r epoxy("prices in \\textbf{{{.comma n_counties}}} U.S. counties") ``` ``` #> prices in \textbf{2,360} U.S. counties ``` --- ```r epoxy_latex("prices in \\textbf{<.comma n_counties>} U.S. counties") ``` ``` #> prices in \textbf{2,360} U.S. counties ``` -- <div class="mv5"></div> This is equivalent to an `epoxy_latex` chunk... ````default ```{epoxy_latex} prices in \\textbf{<.comma n_counties>} U.S. counties ``` ```` ...but the output of `epoxy_latex` chunks render in LaTeX outputs. --- layout: true ## epoxy for .pink[HTML] --- ```r epoxy_html("prices in <strong>{{.comma n_counties}}</strong> U.S. counties") ``` prices in
2360
U.S. counties -- ````html prices in
2360
U.S. counties ```` --- ```r epoxy_html("prices in {{.comma n_counties}} U.S. counties") ``` prices in
2360
U.S. counties ````html prices in
2360
U.S. counties ```` --- ```r epoxy_html("prices in {{strong n_counties}} U.S. counties") ``` prices in
2360
U.S. counties ````html prices in
2360
U.S. counties ```` --- ```r epoxy_html("prices in {{strong {{.comma n_counties}}}} U.S. counties") ``` prices in
2,360
U.S. counties ````html prices in
2,360
U.S. counties ```` --- layout: false class: inverse center middle # Templating small and large --- layout: true # Data-masked chunks --- ````markdown ```{epoxy} {costs_min$cost} for {costs_min$age} {costs_min$type}-based care in {costs_min$county_size} counties ``` ```` 4810 for school-age home-based care in small counties --- ````markdown *```{epoxy data=costs_min} {.dollar costs_min$cost} for {costs_min$age} {costs_min$type}-based care in {costs_min$county_size} counties ``` ```` $4,810 for school-age home-based care in small counties --- ````markdown ```{epoxy data=costs_min} *{.dollar cost} for {age} {type}-based care *in {county_size} counties ``` ```` $4,810 for school-age home-based care in small counties --- ````markdown ```{epoxy data=costs_min} {.dollar cost} for {age} {type}-based care in {county_size} counties ``` ```` $4,810 for school-age home-based care in small counties -- ````markdown ```{epoxy data=costs_max} {.dollar cost} for {age} {type}-based care in {county_size} counties ``` ```` $15,420 for infant center-based care in very large counties --- layout: true ## Tiny templates with .pink[ref.label] --- ````markdown ```{epoxy cost-summary, data=costs_min} {.dollar cost} for {age} {type}-based care in {county_size} counties ``` ```` $4,810 for school-age home-based care in small counties ````markdown ```{epoxy ref.label = "cost-summary", data=costs_max} ``` ```` $15,420 for infant center-based care in very large counties --- ````markdown A study of childcare prices in ```{epoxy} {.comma n_counties} U.S. counties across {n_states} states ``` shows that childcare prices for a single child range from ``` ```{epoxy ref.label = "cost-summary", data=costs_min} ``` to ```{epoxy ref.label = "cost-summary", data=costs_max} ``` per year. This is equivalent to between ```{epoxy} {.pct costs_min$mhi_pct} and {.pct costs_max$mhi_pct} ``` of median family income per child in paid care. ```` --- .w-two-thirds.mt4.lh-copy[ A study of childcare prices in 2,360 U.S. counties across 41 states shows that childcare prices for a single child range from $4,810 for school-age home-based care in small counties to $15,420 for infant center-based care in very large counties per year. This is equivalent to between 10% and 24% of median family income per child in paid care. ] --- layout: false class: inverse center middle # ✨ Shiny Apps ✨ --- layout: true ## epoxy in .pink[Shiny apps] --- ```r radioButtons("county_size", "County Size", ...), radioButtons("type", "Childcare Type", ...), radioButtons("age", "Age Group", ...) ``` -- ```r p( "The median childcare cost for a single ", "AGE in TYPE-based care", "is COST in COUNTY_SIZE counties." ) ``` --- .o-50[ ```r radioButtons("county_size", "County Size", ...), radioButtons("type", "Childcare Type", ...), radioButtons("age", "Age Group", ...) ``` ] ```r ui_epoxy_html( .id = "summary", p( "The median childcare cost for a single ", "{{ age }} in {{ type }}-based care", "is {{ cost }} in {{ county_size }} counties." ) ) ``` -- ```r output$summary <- render_epoxy( age = input$age, type = input$type, county_size = input$county_size, cost = ... ) ``` --- ```r output$summary <- render_epoxy( age = input$age, type = input$type, county_size = input$county_size, cost = cost()$cost ) ``` -- ```r cost <- reactive({ childcare_summary |> filter( age == input$age, type == input$type, county_size == input$county_size ) |> mutate(cost = scales::dollar(cost, accuracy = 1)) }) ``` --- layout: false class: center middle ## Demo Time Field Trip --- class: highlight-last-item ## But wait, .pink[there's more!] -- * You can use `{{ }}` anywhere (almost) in any UI element! .silver[Try .code[run_epoxy_example_app("ui_epoxy_html")]] -- * You can use markdown instead with `ui_epoxy_markdown()` .silver[Try .code[run_epoxy_example_app("ui_epoxy_markdown")]] -- * Mustache templates with `ui_epoxy_mustache()` (and the `whisker` engine) .silver[Try .code[run_epoxy_example_app("ui_epoxy_mustache")]] --- ## Thanks! ### Learn more about epoxy - [Get to know epoxy](https://pkg.garrickadenbuie.com/epoxy/) .silver[(.code[pkg.garrickadenbuie.com/epoxy])] - Would love to hear from you or help you use epoxy! Come to the [discussion board](https://github.com/gadenbuie/epoxy/discussions) - [slides.garricakdenbuie.com/seamless-epoxy](https://slides.garrickadenbuie.com/seamless-epoxy) ### About me - Read: [garrickadenbuie.com](https://www.garrickadenbuie.com) - Chat: [@grrrck@fosstodon.org](https://fosstodon.org/@grrrck) - Code: [@gadenbuie](https://github.com/gadenbuie) .f3.mt4.blue[ 🙇‍♂️ Thank you R/Medicine! ] <img src="images/epoxy.svg" alt="" width=300 height=300 class="absolute bottom-2 right-2" />