All right. And with that, we'll move on to our last speaker of this little block. We have Garrick Aiden Bowie here with us to talk about seamless data-driven reporting with epoxy. So, you see that Garrick, I can see your slides and you're unmuted, so please take it away. All right. Well, thank you very much. Yeah, so my name is Garrick. I work with the Shiny team now at Posit Software. But today I'm here with you as a data person who works with data and puts that data and summaries and things from that data into reports, or namely into text. So, my talk today is about seamless data-driven reporting with epoxy, which is a package that I'm going to introduce today. And I want to start by sharing with you an interesting fact that I learned when I was looking for the perfect quote to open this presentation. It comes from the Department of Labor in the United States, and I'll just read it. It says, 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. And anything like me, one part of you is now saying, wow, children are expensive, at least in the United States. The other part of you is probably a little distracted thinking about the raw data behind this sentence. You're probably noticing the qualifiers like for school-age home-based care in small counties or for infant center-based care in very large counties. You're definitely, well, 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, like 2,360 counties, 47 states, $4,000, $15,000, and the 8% and 19%. And at this point, you're completely distracted from the underlying part of this quote, thinking about the process behind how we got this, these two sentences. Like, where did the data come from? How hard is it to clean? How did it go from rows and a table to this sentence in the report? I mean, that literally like, what happens if we find an error or state updates a CSV file somewhere? Like, whose job is it to come back to this sentence and update it, and how do they do that? These are the things I think about a lot. I like to think about them. And I like to open this conversation today just reflecting on how many important decisions go into our reports and how many decisions are so tightly packed into the words that we write. And all of these decisions manifest for us in a data frame or two. It's extra satisfying when they're tidy like this one. And this table plugs in really nicely into, well, this data frame plugs in really nicely into dense things like tables, which we just saw or plots, which as data scientists, we tend to lean on pretty heavily. So this table we could, or the data behind this table, we could make an interactive plot. You know, like this map showing US showing the median yearly price of infant center-based care across the United States. And this map is great. This is a great tool. It's even interactive, right? But it has its place. No reasonable person is going to use this map to end up at the conclusions that we presented in the quote at the beginning. Here's another example. This is just a basic horizontal bar plot. I took the summary table and I pass it to GG plot mapping child care costs to the x-axis and the child's age group to the y-axis. And I faceted by county size and I set the bar color to the type of care, which is either home-based or center-based. Well, first of all, this plot doesn't, you know, it could look better, right? But getting to here only takes a few lines of code, right? We just give it to GG plot and we kind of write code that do the things that I said. But if we're actually going to present this plot somewhere, we do a little bit more work. GG plot gives you all kinds of tools, you know, and first about, you know, how you lay out data and map data to visual bits, but it also gives you a lot of tools to update labels and text. So with a few more lines of code, we can end up with a plot that looks a lot better. We can give the x-axis or the x-y-axis and the legend appropriate labels. We can format the x-axis in U.S. dollars. We can give the facets and legends better labels. And we end up with a plot like this. So I haven't changed anything about the theme, but this is already a much more pleasant plot to look at. It's much closer to being ready to be published. And depending on the report, I might stop right here. One thing that I think is really interesting about this or one thing that I really like is that we didn't really have to change our data at source at all, right? So behind this, we have this data frame and all the changes that we made were sort of like at the last second right before we turned it into a plot. So thinking about all of these things brought me to work on epoxy as a tool that will help you handle these last mile sort of transformations from your source data into the text that you're writing. I really want this tool to be seamless to help you blend data into reports and into apps. And it also would be great if we could, if it can help us be reusable. So things that we write in one place we can reuse in other places just swapping out the data. Fortunately, there's an R package that works pretty well for this kind of thing called glue. And the advantage, so that this package is great, but it's kind of limited to strings in R. And its biggest limitation is really that it's developer oriented, which means it does one thing really, really well and has basically no dependencies. So it's a great package. And you can kind of think of epoxy as an extension package for glue, which also explains the name and the heck sticker. So you can install epoxy from crayon, or you can load it from from GitHub. And, and then you can use it with library epoxy. And ideally you'd put this into an R Markdown document, but you can use it in R scripts and shiny apps. I've loaded glue, because I'm going to use glue, but, but you don't have to load glue in order to, to take advantage of epoxy. So, just to prove that there's no magic, I'm going to go, I'm going to show you where this data came from. It came from tidy Tuesday, which is a fantastic resource and you can download the data pretty quickly with these few lines of codes.  It gives you a huge data dictionary, which takes a long time to read through and figure out which exact columns you want to use but once you do. You can basically just use a little bit of duplier and the tidy verse to filter down to 2018, the year of 2018 make sure we're using states that are where that actually reported into this data set. We pick out the variables of interest population and comprised in county size. And, and then we do a bunch more work and we pivot and we get everything kind of into the right spot and now we are finally here at our tidy table. From there we can like pull out little pieces that we want. So, in this quote involves taking the sort of minimum from from like the summary of all of the different categories the minimum cost of childcare and the maximum cost of childcare. So, I've now segregated into two small tables that have county size. Like age, cost, and percentage of meeting household income. And then, really quickly, here's just a little summary of the number of counties and number of states. So, how do we get this into pros. So, we are going to use our markdown. So if you're using our markdown you sort of, so I have the quote already so we're going to kind of work our way backwards right. This would be like lines in an our markdown document I've broken it up into a bunch of different like individual lines that we can see the differences as I move through it. And so you probably wouldn't write it exactly like this but it'll help us follow the changes so first of all when you're writing the sentence you don't actually know these numbers in advance right so you're going to so I'll just put blanks where those numbers would be. And now that I'm thinking about it we actually don't know which size of county is going to have the highest childcare costs. We also don't know which type of childcare or or educational center, you know, would have the highest or lowest and we also don't know which age group it would involve so these are all things that we like don't know and we want to bring them in from our data. So if you do that in our markdown would be to use inline code chunks you. You get to wrap the variable of interest in these back tick these like back ticks but you add this little R in front looks a little bit like that. We can use and counties number of counties number of states. And then we could fill in with our minimum cost information, we could fill in with our maximum cost information. Right and now we, we now we have an awesome plot right, or sorry, awesome text, almost it this looks. This is good like this is amazing it is amazing that we can do this. But it's also just fine like there's some things that are bugging me here like 2360 or this odd formatting of this number and these are supposed to be percentages right so that's going to bug me and we have to fix it. One way you could do this is you could write inline code or you just like write more code in line. So here I've gone through and I've added the format function and I've added arguments like big mark and I've done some rounding down here and you know a couple of things, rounding and multiplying by 100 and stuff like that. Okay. So now it's time for my spicy hot take of the talk, which I guess I'll actually give a spiciness rating of just one pepper this probably isn't that spicy. Okay, write our code where it can be our code. That means so like here, we're writing text, and then we put a whole bunch of our code inside of this string. I'm not a fan. A better idea is to put it in an art chunk. So in an art, our chunk is basically the same as like putting in our script. And there it's like colored in it hints and you got all sorts of stuff. And that's great. And it but an even better option would be to use use some formatting functions that are really good at doing this thing and and are, you know, can do something like take your dollar and or take your unit that represents a dollar and actually turn it into a dollar, which also is then easily translated to the other currencies like the URL and other things. Okay. And like, like, how, why is this better.  So like static code utilities and things like that are not going to find your code that's in inline chunks. So it summarizes up as also inline code is for the simplest code that you cannot possibly mess up on, like, you know, you know you're what you're doing is going to work. And you're not going to make a typo. Right. How do we do this with epoxy so going back to this. Before we added in all the formatting we're going back to just it's in line. Inline our chunks. First of all you add library epoxy somewhere in your document, and then you can use an epoxy chunk. And so this is a little this is probably the one weird thing that epoxy asks you to do is to put your art your mark down in and in a chunk with the engine of epoxy. But I hope we can go and get past that. So the next bit is to the final these parts where you've used inline our code, and we're going to replace them, instead of doing back to our space variable and a back tick, we're going to put curly braces on the things. So, just immediately, I feel myself getting a little bit calmer this is a little bit easier to read, I think. And in case you're like, well, what is like, is this does this really work. One of the really cool parts about this is that if you're as you're typing, and you get to the part, like here where I've trying to type costs, you get autocomplete this in this chunk. This is the thing that the idea does now actually for inline our code but it didn't used to so this is pretty this is cooler like two years ago. Okay, but what do you get out of this, you get basically the same thing like it's pretty close. It's, it's pretty close. It was it's nicer to write as part of it but but we really want is women and we wouldn't be able to do this formatting So, let's look at this. Let's go back to our inline our code. So I have cost dollar max inside of inline our code. And to make it an epoxy chunk I wrapped it in braces and curly braces. And here's the cool part that epoxy does is you can add a little dot, and then a name of a transformation that you want to perform on the thing that's in that in that braced section. So here I want to make costs max money I want to represent it as money. I want to turn MHI percent into a percentage. And I want to do, I want to apply comma to and counties. This one probably seems a little bit weird. I mean you probably know what this is doing but it comes from scales. So if you ever use scales for ggplot it comes from the label comma function. And we're actually using scales behind the hood. That's why I wanted to kind of show you this. So if I go back into my chunk and here I've made it just a little bit more more normal looking without all the new lines. You can see I've now added things like comma and and counties and I've made dollar cost max and percent dot percent for this percentage. And now I have a pretty nice, nice quote that looks a lot more like what we want at the end. And one of the things I really like about this is that we're in, you know, these transformations aren't happening. We're not having to do this somewhere else we can kind of leave our data alone. And it just plugs in nicely here. Okay, so this is all powered by glue. And which means that also all of these that the epoxy chunk that I just showed you is also a function called epoxy. So glue doesn't use the same syntax the syntax comes from glue where you have the the braced expression that that gets replaced. And, and here, here's where like it don't write code in strings, like really don't write code in strings, as much as you can avoid it, right. And epoxy is a drop in replacement for for glue. It changes a few little things to make it easier to use in reports and places where like we know that you're wanting to write text and you also have to think you have work to do and you want to get it done. Right. So, this syntax is not part of this dollar dollar syntax is not part of glue it's not something glue does it's something that epoxy ads on top of glue. And also, I should mention it's heavily inspired by the CLI package by get worse is already, which is an awesome package, if you are looking for making command line tools. Okay, so these are the same thing, the epoxy chunk in the our markdown document is the same as calling the epoxy function so the same ideas work in both places. So, here we go with inline transformations here you can see that they work like the do in the chunk. How are they, how are they, like how do you, how do you change the default right so one of the things I'm not really liking is that this is a, you know, it gives you sense. So, it's done through the transformer argument which is actually the same thing as the transformer argument for glue. And we're using the transform inline which gives you these transformations. And I can then say the dollar transformation is uses scales labeled dollar by default, but I can also add in their accuracy equals 10. And now my my for this particular transformation, we're going to round up to 10. You might want to do that like everywhere like say every time I use that dollar I always want it to be just like whole dollars, in which case you can use epoxy transform set and give it the trans these transformations which then become the default transformations anywhere that you use epoxy. Here's some other cool things you can do here I've just grabbed out the age, like summarize the age and I want to say like children were in the age groups and they give this ages age here is a vector. This part right here is a vector and glue is vector I see you get like by default you get four strings with each level. But what I really want is to have it say infant toddler preschool and school age and so this is the dot and transformation. I might want to say or infant toddler preschool or school age and I can use the dot or and transformation. And what if like just for this example I decide you know what I really wanted to say to instead and do that. That doesn't exist that's not something that that epoxy gives you by default, but the good news is you can make it yourself. So using epoxy transform set again, I can define the dot to transformation as a function, it takes one argument that gets the result of this, and it performs some transformation to it, it collapses it, and then we say the last one is going to be to. And now it's to so any transformations that are like a thing that you want to do ready that like are specific to your report. These this is the way to go. You can also nest these transformations so you can say, I want to do that too, I want to do that to transformation but I want to apply title case first, and you get title case variables. And, and then a few other things. The other, the transformer things kind of neat and you can, you can actually chain transformers so here I've said, I want to use my inline transformer so I get the dot date transformations, but I also want to bold every replacement that you do I want to make a bold. And, and that's where you get this markdown. It's going to be bold in the end. So what if what about latex latex is supported. There's this weird thing that happens where like you have to escape the, the braces and I'm just going to show you jumping to the end. You can use epoxy latex, and it will change the default so that the delimiter becomes these open alligators. And similarly for HTML. It become it's to braces. There's a whole lot more that epoxy can do. And so I recommend checking out the slides and taking a look, or going to see the package documentation. Thank you. We have a discussion board. And you can find me online at these places and I appreciate you listening and I hope epoxy helps make your reports more fun. That was really fantastic. I have used a lot of inline code and glue, but I was not aware of the great functionality in this new package. So thank you.