image: thumbnail.jpg
Open Source Chat - {gt} with Rich Iannone
Key Resources:
⬡ Get started with {gt} - https://gt.rstudio.com
Reach out:
38:48 - How do I ask Rich about {gt}, feature requests, bug reports, how to solve a problem via {gt}? Rich and the {gt} team would love to hear from you.
⬡ Feature requests & bug reports with GitHub Issues, https://github.com/rstudio/gt/issues
⬡ GitHub Discussions, https://github.com/rstudio/gt/discussions
⬡ Ask the community a question, https://community.rstudio.com/tag/gt
⬡ Follow {gt} on Twitter, feel free to reach out and ask questions, https://twitter.com/gt_package
Timestamps
Rich Iannone Introduction.
03:52 - Why {gt}? - What does {gt} bring to the table? Why so much effort into static, data display tables?
05:50 - Why open source? Why is {gt} open source and why have you dedicated your career to develop open source software?
08:30 - {gt} v0.7.0, Tell us about those new vector formatting functions in {gt}. Why did you include them? Could you show us some examples?
{gt}'s vector formatting functions help you customize the styling, look and feel of your values. Converting the output values R gives you, and making them look exactly the way you want them to can be tricky. A lot of work was put into {gt} to give nice value formatting options. You can now access all these outside of a gt table; e.g. in text, in a plot, etc.
22:35 - Could you provide an example or two with the new styling function called `opt_stylize()`? What kinds of tables can you make with that? Can you extend that with your own tweaks?
28:15 - Can you make your own themes and share them? "How do I create my own custom theme for my table? A theme I can share with the rest of my organization?"
31:58 - What is the distinction between tab_options and the opt_* functions? Why would a function be in opt_* and not tab_options?
34:00 - sub_values() function, to find and replace certain values in your table.
36:50 - What is the current support for latex in {gt} at the moment? "Personally, I much prefer HTML, but for scientific publications, we are asked to provide a LaTeX file."
42:50 - "In my work, I often produce A4 output in PDF, mainly with ggplot2 content. It would be nice to be able to combine ggplot + gt tables in a similar way {patchwork} works. Having the plot and the table next to it is very useful sometimes."
44:30 - Interactive Tables with {gt}?
47:45 - "Any plans to make applying of same style to several columns easier? Unless I'm mistaken, the locations argument of tab_style requires one to specify an individual column. See here: https://gt.rstudio.com/reference/tab_style.html#examples." Yes, supply a vector of columns or use tidyselect functions.
49:15 - "Excel output with {gt}? Would be a huge improvement. I often have to produce tabular output that can be easily reused. Usually it means Excel tables. So far I have mainly done this with Python and openpyxl or PyWin32 (through COM). A simple solution in R would be great."
50:20 - Support for additional output formats with {gt}? Excel, PowerPoint, etc.?
50:25 - {pointplank}, a package to methodically validate your data whether in the form of data frames or as database tables., https://rich-iannone.github.io/pointblank/. Check out the workshop materials at https://github.com/rich-iannone/pointblank-workshop
55:50 - "Are there ways to have grouped rows? I mean when repeated rows have same characters can we merge them to one?"
58:00 - "Is there an ability to add 'battleship coordinates' (e.g. column letters & row numbers) to a gt object? This is a standard for table across my org and I’ve been trying to figure out how to implement it."
59:59 "Do you have suggestions or examples of building out & applying corporate formatting to gt tables (e.g. adding a company logo, company colors, etc.)?"
01:04:30 - "With PDF/LaTeX output for wide tables, it does not shrink the table."
Transcript#
This transcript was generated automatically and may contain errors.
so thank you everyone for joining uh really appreciate it so this is uh the first this kind of a pilot of what we'll call an open source chat so what what is the goal of open source chat it's a lounge curtis a lounge excuse me yeah i brought my water too so this open source chats okay or lounge yeah there's two main goals i am curious what you guys prefer so first and foremost goal is just to connect users of the tool to the people who develop that tool so developers can sometimes feel a little disconnected from end users it's probably not a case with rich here and then users often you know are unaware of how these open source software tools get made and get maintained and then open source software just works better with an active and engaged community and a better connection between developers like rich and end users like yourself or other contributors developers like yourself and then secondly just thinking this as an opportunity for you guys to share with each other how you use the tool and how you approach common problems so with that in mind we would love to hear questions from you i'm curtis i work at RStudio soon to be posits on the community team and we'll introduce rich in a moment also a good portion of you may be watching this in the future right after the live event and you know i like to imagine this post-apocalyptic landscape in the distant future where someone has somehow got access to a youtube data center or something um if you have those questions just go to the gt package twitter accounts rich would be able to respond to you there it's a good account yeah yeah cool so
just introductions um so this is rich uh he's on the RStudio's uh cordo team soon to be uh posit where as as you may or may not know RStudio is changing its name deposit for a number of reasons and is the maintainer of the gt package the gt package strives to empower anyone to make wonderful looking tables with r the philosophy is we can construct a wide variety of useful tables with a cohesive set of table parts and then this is done uh with a r package that has a number of helper strives to be intuitive and easy to use and helps you make kind of custom tables so there's many helper functions that help you modify and customize your table it sort of assumes where you start with this data frame and then a table is built up of stubs summary rows titles of titles columns headers footnotes source notes and then there's a number of formatter functions for the values of that table and then uh the other goal is to have to offer you a wide variety of output formats currently supported is html pdf or latex uh i think it's latex to have pdf rich checks rtf files uh which i love that it's called rich checks files since we have rich here and then recently added text files sorry recently added is was word doc um so most questions uh will come from the audience but we have pre-arranged a bunch of questions just to kind of get things the ball running but we we do intend to switch to this discussion and questions from all y'all and then so if you work with gt actively now if you have feedback if you're struggling create tables that you need this event is designed for you it's very much interacting with with rich as the maintainer of the gt package so yeah thanks for joining us
rich yeah thanks for having me this is great the inaugural lounge event yeah i really appreciate you doing this uh pilot and experiment yeah and i and i also really appreciate everyone who's joining us as well so just the first question to get out of the way is um how do i pronounce your last name because i recently learned i mispronounced it yeah it's a tough one time um i go with ian or you know it's tough in is probably the best your best bet so ian none as it's basically spelled here but yes yeah yeah okay awesome so i should know that next serious question is i look back at your talk and i think 2019's uh our studio conference you joined in 2018 i've been working on this since may or march of 2018 more like me um yeah yeah yeah so i mean if you could i gave a little introduction to gt if you if you could kind of give your introduction and and why are you spending so much time on the right you know why are we why are you investing so much into this yeah i think it's mostly because there's so many problems to solve um i worked on it um we had the initial release like in late 2018 and then soon after tons and tons of issues um which was great you know i love issues um but they're all sorts like little things like that some things i thought of but some things i didn't and i'm still getting these issues even with lots of like um changes and tweaks and additions uh i think there's just so many things that people want out of tables because it's kind of a creative pursuit and um it's a bit like a visualization in a way there's no like hard and fast rules you can do whatever pretty much as long as you have some sort of grid of numbers or uh or you know otherwise but yeah there's tons of stuff to do so i just kept doing it nobody told me to stop um yeah and there's so much to do especially in just a static table um scenario just like you know tables on a page or on a website um yeah yeah i think we're almost getting to the end of like the conceivable things that people want that's why i'm sort of shifting my attention to like other things like um you know those questions i had you know branching out yeah other output formats or getting interactive um but i still i still think there'll be a lot of work even in the non-attractive case because there's so many small things you can do uh to make better and i i have a kind of a set i warned you about this question it's a little bit vague
Why open source?
but okay um just to set things up right as a company what one of our goals is to support open source software for data science so can you tell me like you know you could conceivably working as a developer at a fancy software company not that posit is not fancy but yeah so so why are you investing so much into open source like why why is this an open source package why why do you care so much yeah why do you open source in general i think it's great because you have this um interaction with the community you get like issues you get to talk to people on issues you get prs people are sometimes sitting in their first or uh maybe they're experienced you know we have different levels of people coming in uh but it's great you're helping people sort of like you know contribute it's like all about um interaction and contributions and uh it's great to see something like develop kind of like semi-organically that way i know like you know like the maintainer probably but it can be totally steered and shaped by by people in the community and i think that's kind of wonderful in a way so what would be your message to why right if i have some options for developing a any sort of software why as a user would i maybe prefer open source over some alternative that's not oh yeah yeah yeah lots lots of reasons um well one thing is like if you see like a thing that you want or something that's not quite right it could be a bug or an enhancement you could just make the pr and convince the person to accept it or you know like work towards getting that accepted and that could be really fast i've seen it happen within a matter of you know in best cases hours um you know sometimes it can happen over a longer period but it'll happen way faster than closed source software i can tell you that at least have a fighting chance with open source and like if the project is active um it's extremely fast it's it's amazing actually how fast you can make changes and how much you can sort of help a project out just if even if you're on the outside
at least have a fighting chance with open source and like if the project is active um it's extremely fast it's it's amazing actually how fast you can make changes and how much you can sort of help a project out just if even if you're on the outside
What's new in gt 0.7
awesome well thanks a bunch um well so as a reminder to folks um feel free to ask some post some questions into into the zoom chat as well as if you're keen on more of an anonymous type structure um there's a slido link at rstd.io slash os chat feel free to drop stuff in there um the second half we'll switch to discussion that sort of thing um just to get the ball rolling uh we've set up a couple questions uh focused on gt gt 0.7 just came out um could you kind of introduce you know what's in gt 0.7 and tell us a bit about what one of the parts right is this vector formatting functions yeah that's kind of a big thing um okay there's two like really big things uh the first is uh the first support for docx output like word output format it's not just beginning so um you know keep your expectations not too high because it's just beginning so there's going to be a few like sort of like things to sort of like patch over uh but at least it's a start so we've got that sort of going um the other thing is yeah this uh the vector formatting functions um and i can show you that because it's kind of big thing so we spend a lot of time making these formatting functions so you can get your values and whatnot formatted just like how you want them
i'm going to share my screen and i'll show you i got this like document i set up and it's got all these things in here and it's actually a lot of functions if you look at these these are all the functions i added in in 0.7 they all begin with vec underscore fmt so the existing functions are just beginning with fmt um so those are already in the package like pre 0.7 but we add these ones that begin back and continue on the same name so the idea here is you can just like use those formatters uh outside gt if you want um so you have a vector you just format it and you have the same arguments that you would have uh in the sort of like the function that was there before so it's better to show than to tell because it's a little confusing um so let me just show you so i got this vector of numbers just uh you know some some numbers and i'll use vector format number on this and then if you look at my console it just formats them to two decimal places because that's the default uh for that so i can change that to like three decimal places so kind of neat so we're totally outside of gt we just have a vector and we're using the same functions that you would use to format columns of values we're using outside so why do this well there's this thing called r markdown in Quarto or you know other things like that you may just want to have formatted values in your text so you can have these inline sort of like um r pieces or r chunks and you just throw in like a vector like a vec format function in there and you know get the same sort of treatment as you would in your table which is super cool uh so i'll show you a few more examples just to acquaint people um so you have some options here for the separator mark and the decimal mark you can change those so basically those are reversed um so other you know locales will have that by default so you just insert the locale like here's france and we have the same sort of thing right there that takes care of that there's a bunch of options basically the same options as i said that are in format number which is this function here
and here's the help doc basically all these carry over which is kind of cool um so if we did this for sign equals true just a few more examples that means like you get a plus sign always that's pretty good if you want to show change from a value uh drop chilling zeros so that means like any zeros that are at the end will be dropped accounting we have that and you can always use a pattern if you want to adorn your values with some sort of text either before or after so that's like a sort of review um and it's kind of neat because this is just like in the console we're getting our values just formatted yeah um this reminds me of scales a bit like you often have to pull in scales yeah ggplot2 exactly so we have exactly so we have vector format currency and we do the same sort of thing with numb bells and speaking of which there's in scales sorry um dollar and you can do the same sort of thing like uh num bells i believe works same sort of thing except in scales there's only dollar and euro i believe and there might be pound but uh you know vector format currency has basically every single currency type so which is kind of neat so you can just choose the currency in there um so that's kind of neat so same sort of use case um if you're using this outside ggplot2 just inside text uh you can use these they're sort of interchangeable uh which is kind of neat yeah
i can i can imagine you put a ton of work so that you your users could customize the look and feel of the value within the table that's yeah i you've showed me you know i've gone through sort of if you include all the parameterizations and all the examples of those we're talking about hundreds of different ways to look at things right and so basically with this is it's now available outside to anyone so you could put it into a ggplot2 or a plot exactly or inside text inside in line or bit yeah um i'll show you a new function we have there's actually two of them because you know we have this two like a set of two now uh format duration and vec format duration uh it's kind of neat because i can just like provide examples with the vec form and just show them the console it's kind of like a nice way to avoid seeing a table each time um but this is all about duration values um you may not use them very much but if you need them this is great because it provides so many different ways to like provide these human readable durations uh so like you know 81 weeks two days 20 hours 24 minutes 32 seconds it kind of does that automatically uh so i don't know if you know about diff time values but there you can use those or you just use numerical values and provide the unit so two different ways to sort of like put your inputs into this uh but there's like tons and tons of options here so again i use that help a lot uh if you just go to format duration uh you'll see just a pretty large number of like different like arguments for tweaking um the values and of course i provide examples here at the end but let me just show you a few of these just to give you a flavor of what's in there so we have that uh we can also like just constrain the output units so this in this case is just days we can provide a vector like that and we can also it's a little bit off the page here but change the style duration there's four different styles so y just means we're not using h or m we're using like the the words essentially like this which is kind of cool and uh a big thing i do in gt is because i know this package goes all over the world is have locales like a locale setting in each writer
function and that should basically this is not a machine locale it's basically independent from your actual setup but if you put yes it'll produce like spanish um durations which is kind of cool
if i build a shiny app and i somehow collected locale information from the user is that something i could pass on or is that sorry that's yeah absolutely yeah like there's tons of lookouts so if i just change this um like it's that so it's like i think 700 and they're all translated and formatted correctly uh because there'll be all sorts of like differences in the way this is like patterned so so a lot of time went into that uh making sure that worked
so but i'm really happy that we have all this like for every single formatted function now um we also have another one i just want to show you one more it's the scientific one because i want to draw your attention to like some special stuff at the end um okay first of all scientific notation a new thing is now we have like a plain version of like scientific notation so this right here if you look at this uh it's just basically like meant to be sort of like inline in a console this is called the plain formatting style and you don't really know this but by default there's actually a output which is called auto so in the console it'll just be plain but you can force that to be like plain like this um so i'm just going to zoom ahead and sort of get at what i'm trying to show you
this output argument it now like can make the um it can make the outputs like html latex or rtf so i'll show you that because you know this is stuff that's kind of hard to type out or to format yourself but if you have an html document it's perfect because it'll be formatted nicely if you have a latex document same sort of thing sort of stuff that's a little bit hard to write yourself maybe impossible to do in like gt right now anyways rtf is right there so the idea here is because we have it as auto we can just put this in like Quarto and it'll detect what the output is and it'll just choose so if you have an html document in Quarto it'll choose a nice formatting which is basically using tags so let me show you that um so i haven't i had no idea that yeah that's amazing yeah there's like so much stuff going on that's why it's like oh my god i gotta show you all this uh so we have a Quarto document right here
so we're just setting it up with a gt and tinyverse uh we're making a table uh there's a nice data set inside gt called pizza place i make a pizza summary i make a table and then i display the table finally great okay but the thing i want to show you is the new thing basically in this little inline code chunk uh with the backtick r uh so i've got an object pizza summary which is a table and i'm pulling a value out of it and then i'm getting the max one the the max element of the vector and then i'm using one of those vector for my functions and i don't have to like specify like the type like the output it just auto kind of knows um what we're doing but this is really kind of neat because like it gives you like the html like formatting and with diagonal like as a layout it's got a nice slash and like the number on the left is superscripted and subscripted on the right kind of hard to pull off if you're just doing it yourself um but you can do it here which is kind of cool um and there's also some a bonus as well
in version 0.8 which is not released yet but it's in like the dev version we have another function called extract cells which allows you to just from a gt object take a format cell right out so you don't have to like redo all this stuff uh so there's like two ways to to do things so basically the formatting that's applied will just be like taken and put into the uh into the document let me just show you that i'll render this yeah i feel like you've been setting it up and teasing last setup yeah but uh the final result will be really cool but it's good to see like you know where it's coming from and you know the source and the output okay so here's the table well here's the source for the table the table so you can see we have fractions here nicely formatted uh really cool but here in the text look at this uh 5 over 10 in that sort of fancy html way so with tags uh same here what we did here is 2 out of 10 because we've targeted the column f sold you don't know what it is because it's actually um you know like right here in this pizza summary or actually no it's in the gt table and then um rows 14 so we just grabbed row 14 which i believe is the last one and it's 2 out of 10 so basically this formatted value you don't repeat that because it already knows what the formatting is you just start grabbing it and then putting here which is super cool if you want to cite values in a table you don't have to like you know like run the risk of having formatting errors or like transcription errors you just like you're just pulling it which is kind of neat uh so that's one to show you there that's like one of the sort of like cool things about um the vector formatting functions and then you function extract cells does gt have a cheat
you just like you're just pulling it which is kind of neat uh so that's one to show you there that's like one of the sort of like cool things about um the vector formatting functions and then you function extract cells does gt have a cheat
sheet because no i guess i feel like the back of that should probably be just showing you giving you a sense of the scope like like i said yeah you have a couple dozen functions and then when you include all the parameter options you're now getting into hundreds of ways to customize yeah like we yeah it would be awesome to be able to quickly review kind of what our options are so i guess it's just assume that there probably is an option and then dive into your docs to if that's that's pretty much yeah what i've done to help that is to make the man files like the help files here at least as much informational as informational as possible um they're huge documents but they at least have examples and i try to like you know flesh things out in like detail sections right here like this if it warrants more explanation but at least try to have like reproducible reproducible examples um so this table like this code will produce this table and there really should be more stuff like that um but you know at least there's like a guarantee of one per help article and also the other thing i pledged to do was for each help article just show one function instead of like a bunch of functions at one time uh less confusing and uh kind of gets to the point a bit more i mean it's more documentation to do but that's fine so be it um yeah so but but yeah http would be a good thing i gotta get on that um that's the thing i should have done
opt_stylize and table theming
a lot for the for the second time let me just jump to that because there's two more demos you wanted to show off that highlight uh 0.7 and then we got several questions so i think just let me just jump to those right now too because uh i at least know this this next tier you you were pretty keen to share as well um so yeah in g in in 0.7 um there's a new op stylized function which is sort of like applying i mean you're about to show us but it's sort of like applying sort of a theme to a table so you could have multiple tables with with minimum effort to kind of have different similar looking tables or similar themes applied to it so yeah could you provide an example yeah with the new styling function uh yeah what kind of tables can you make with that can you extend that with your own tweaks um and then second part question which i asked you and i know i've seen uh is you know similar to ggplot2 themes where it's really easy to build your own theme is there what kind of support is there for that now for building your own theme like a company theme or a personal theme and uh applying that yeah so thanks yeah i can definitely get to all those things uh so yeah the new opt stylized function it's great um i mean let me show you so i'll make a table and i'll show you that table we're finally seeing a table which is kind of cool um so i'm gonna run that and get it right here in the viewer okay so here's my table um so this is just like the default you look like just a plain table coming out i mean there's a bit of formatting there's like all the different sections like summary rows this is a grand summary as you can see by the double line and it's got some like you know it's got a footer section a title a stub on the side
and group summary rows great it's got all the all the all the parts are there uh but now we can we can style them uh so yeah we do the opt stylize and look at this there's like so many options because there's six colors uh that we chose and six different styles that makes three six different you know like jumping off points so so let's let's show you a few of them here's one okay so look at that uh so it does styling and that's in the blue color we have cyan i'm just going to run through them pink red and gray so why do we have just these colors the reason is we want to sort of carefully curate this in order to get maximum contrast uh between like you know like the text and the background colors and just to get some sort of harmony we chose actually a number of different hues and it's more apparent we look at different uh like the different themes like the different numbered styles like for instance this one it has like a dark blue and a lighter blue and uh perhaps even lighter blue or yeah something in the middle there's actually five different hues for each color and um it's interesting like i called these styles one you know just one to five and then just last night when i was like preparing this i was like maybe we should have names for these different um styles so i took a stab at this you know like this is like almost a colorful stub because at least you do get a color there uh this one draws your attention to the summaries because both of them have a background color uh this one is dominantly gray but it at least has some color at the top right there and this one has you know a different style in terms of like dashed lines a few of them so i try to make it a little bit different so you have jumping off points because this may not be the thing you really want in the end like if it is that's you know it's fantastic um but it might you know it might need some tweaks
right but the great thing is you can do that uh because all the changes you make are sort of like additive in the end uh so we have this example table for instance and we use off stylize uh style five color green looks pretty good uh but maybe you don't want the row striping you can sort of see that here in rows two and four and further down as well uh we can give her that just with opt row striping false now that is going to be gone oh sorry i included the pipe try it again there we go so that's it that's a tweak we made so away from like the original sort of like theme uh result uh maybe you don't want the outline that's around the table you can move that as well great now we're getting somewhere uh say you want the table header to be aligned left no problem we can do that nothing else is disrupted it's basically just like independent of everything else and maybe you want some other options like and there's tons of these i kind of like i am both proud and also a little bit embarrassed about how many options are in tab options so it's a bit unwieldy but it gives you at least tons of control like over the look at the table and it's not hard to use once you know where to look so for instance can i ask about that as yeah kind of a design question uh why are you embarrassed about that like are you suggesting there's like an alternative article it's you know it's massive uh so tab options um i mean this is an area where we can like we can just scroll and scroll and scroll i mean this is okay i mean i think ggplot2 has something similar to this otherwise yeah it breaks it down a bit more um but you know it is at least all in one function it's kind of like um it's a lot and there's lots of explanation at least but you know like i can understand it would overwhelm
um there's some examples more than the usual amount but i believe this deserves like an article um just to you know go through all these things but if you do need to change things table-wide and not have to resort to like targeting specific areas with tab style uh this is a pretty good place to go so for instance we can change like the the vertical lines and just get rid of them like none uh we can uh add a top and bottom border to the table so let's take a look at that whole thing there we go so now we have that that line there and this line down here at the bottom and the theme it's weird it has like invisible things that are not turned on so um if you do turn them on like this it'll be part of the theme although it's kind of like not there sometimes it's a bit strange um but yeah so this is an example of like taking it further you know starting with up stylize and then you know like uh tweaking to your satisfaction so if you're like a company and one with one like your logo in there um you can probably do that just by inserting like an svg or some sort of graphic in the header or above that um unfortunately i don't have an example of that um but maybe i'll have that for next time because that seems like a pretty obvious thing
Building your own theme function
uh okay more about theme so say you wanted to do this all the time you could definitely make your own function uh so i have a function here called my theme uh pretty simple all i did was i took this right here replaced example table with data but that's you know the only argument in the function of my theme and then um this should totally work i mean even if you don't have these parts like if you don't have like a tape um like a header this the function won't stop it'll just do with it what it will and not error out so this is kind of cool so my team we have that function here's the example table and here's the example table with my theme there we go
and is that additive on top of it too like if i wanted to then suppose there's a company theme and i then wanted to tweak it you can keep going yeah you can add different options you can have as many tab options calls as you want like that so yeah definitely um so yeah i think so even more about dating if you really want to make your own thing and maybe bypass up stylize you know just go a different direction you can make you know i call this function my super custom theme same sort of idea data is like the argument you can call anything you want it's basically just the gt table and you know use tab options and again it's huge but it kind of like lets you target different areas this is just at random so it's gonna look it's gonna look terrible but i want to show you this oh and also isn't this cool like the new ide for RStudio shows the colors that is so incredibly helpful um because sometimes i'm just guessing and if it shows a color it's like oh yeah i got the color right so yeah let me show you that so this is my weeks that's helpful yeah but yeah still yeah like i'm just guessing old names that i might know okay so here's example table
and this is with my super custom theme apply there we go so basically it's like making your op stylize function in a way and this is kind of what op stylizes mainly doing in the in the body itself of the function sort of an inside look uh but yeah here's the table so all the different sections are styled according to this so kind of neat
um where do you think development is going to go with this um i i've told you about this before i've seen one one or two message on twitter where yeah like i like the ggplot is sort of a really nice standard as i understand it's a pretty good nice standard um is this sort of the way you're going to be encouraging people to have this sort of uh theme that you could apply to multiple tables i think so i think so like you can either do like you know just have like the different you know statements or you wrap it up in your own custom function i think this is the way to go and just maybe some more documentation around this because sometimes it's hard to imagine you can do that um yeah or whether it would work really well but you know having a little recommendation there in the docs would be uh my next step with this
because i think the model is not bad i mean you can overwrite things it's kind of like a settings table which is just basically like you know like just set i guess or and yeah it's nice that you can sort of iterate rapidly you know with this and run the function change a few things run it again and then you have a function you can use over and over again
Design of opt functions vs tab options
um we have a bunch of questions coming in and some we'll get to in a moment but one is actually very much uh fit to to what we're talking about now um so max actually max would you like to ask the question it's i mean it's just based on what's on the screen right now
uh sure thanks yeah um yeah first great prat great package um some really cool things here but i was just wondering what the kind of design distinction is between having a function in the opt set of functions opt underscore and then having tab options like why would something be in tab options and not op stylized yeah yeah i think part of it is tab options just being so big it's hard to find important things out of that so basically what we did with opt functions is try to elevate a few things that were hard to find or it is a combination of things of different settings which are changed in tandem which might be not you know incredibly not obvious at all
uh like for instance uh well i'm not gonna go through the code but the opt stylized that changes a bunch of things in tab options that and provides a simple interface you just need to host a style number and then just have a color that's you know one of the accepted colors it'll change a bunch of things for you to have options you'll have to hunt through them and like especially settings there's like at least like two dozen things which are changed with just this function um things like striping it just that is less the case i mean there's probably an option inside uh tab options that does that but this just elevates it and exposes it makes it a little bit easier to find and discover so that's some of the things either it's like way too complicated or it's hard to discover those are the things that sort of warrant or maybe think that the opt functions you know have a place in this package
either it's like way too complicated or it's hard to discover those are the things that sort of warrant or maybe think that the opt functions you know have a place in this package
Preview of sub_values in gt 0.8
i've also got more if you you're okay with me showing it to you yeah yeah go ahead we and maybe after this we'll switch to i have there there's so many questions on twitter that kind of fit into nice themes that i think would cover a lot of uh questions that people have so we'll get we'll get to those right after that yeah okay i just i did this last night like this little document i was like i just wanted to keep going because of this you know it's kind of nice so maybe this inversion 0.8 preview i have like one function i do want to show uh which is really super neat it's like it's been asked about for a while it's basically just like a find and replace uh you know with whatever value with a new value and it's fine it's kind of nice actually um i don't know why i didn't get to it earlier but uh anyways at any rate we'll be here soon with 0.8 uh the function is called sub values and the idea is okay i'll just make this table great and so if i just show in gt just to get like a basis
so you have this table this make believe table and uh there might be a scenario where you just want to place certain values like you know like 74 and 500 are just like example values they're just literals like you're just searching for them and you want to replace with some other value so you can totally do that here it's an easy interface just for like making quick tweaks and it's kind of nice because you can format these values before and then just like sub in some new values and it doesn't it doesn't like affect or alter any formatting you've done
which is pretty cool uh so like you know a value like b could be replaced with the word b or 800 could be 800 like this so it can't be flexible it could be different types here it just searches all across the table you can definitely constrain across certain columns if you don't want the you know replacement to be like too much um but at simplest it's basically looking at all values and just it's simple find replace either on literals uh here we can use a pattern like a regex and then do replacement so here it could be ac or e is replaced with the word ace and then if you really want something uh a bit more flexible you can just have your function in there and then do a search across values or whatever you want to do to target uh values so in this case any value which is greater than or less than 50 will get this text that's kind of cool because it just skips over things which are like character columns it doesn't like stumble over those and error out
so that's a little preview sort of like the post-credits scene i guess you can say for this um yeah yeah i want to show you that awesome
Participant questions
well if we could uh switch to some um participant questions uh i'm gonna jump to slido first so those were the anonymous questions and also just a reminder to everyone uh feel free to drop any comments or discussion topics or questions into the zoom chats if you want to do uh uh anonymous we have a little slido link that i'll share in chat in just a moment and you can ask those there there's also a nice poll that will be a discussion topic as well
um but yeah so first anonymous question is uh yeah what is your current support for LaTeX at the moment uh personally i much prefer html but for scientific publications we are asked to provide a LaTeX file and then also i guess fitting to that what would be your suggested workflow like a lot of a lot of docs are sort of assume i'm going to do everything in our markdown doc or everything in a Quarto doc and that's my the thing i submit but very often you know i just need to make a table that then a co-author uh incorporates into an existing you know highly customized LaTeX doc yeah so you're sort of exporting it out you're using gt as a tool to make that table but ultimately you're going to take that code and put it in a different document that sort of away from like r markdown the corridor
yeah i think with LaTeX we want to make it better it's not nearly close to parity uh with html as it could be i mean certainly some things that are in html can't be in LaTeX because it's paginated but a lot of things can't like cell backgrounds and changing colors and having just raw LaTeX text if you want to circumject that that's sort of missing um the reason why it's missing is because i didn't see there's much demand for that yet usually when i look at the LaTeX tables um they're pretty unadorned with things like color and other things like that they're pretty much almost like box center tables i kind of have to wonder if that's because it's just really hard to make tables with you know all sorts of things in it because you have to use packages and things like that um but i almost feel like if you had the option maybe some people would use that so it's kind of that weird standstill right we don't really know how much we need to do in that if it's you know like if that export option is satisfactory or not certainly i get the indication that it's not quite there because some people prefer to have at least those few things in there
How to reach Rich and the gt team
um so i think we'll address that i'm gonna be asking you this a couple times uh yeah if i was a gt user or potential gt user uh what how do i let you know what i want and need or would like lots of ways yeah lots of ways so yeah the LaTeX tables are a nightmare i understand um basically uh issues issues is a great obvious way uh other ways is it captures things and sort of puts it on the record and it's actionable by me uh another way is the discussions inside the github repo for uh gt there's a a new sort of feature it's not that new anymore but it's basically a part of github it's called discussions if you feel something is not really like an issue or you just have a question or something like that put it in there other places RStudio community usually i see all this stuff so that's a great place um stack overflow is not that bad because you usually have other people answering your question quickly and it may be just like you'll find it's a bug so you'll just end up you know you might end up like posting that bug as an issue in in the gt repo uh so lots of ways um those are the few obvious ways it could be like twitter as well like on the gt underscore package account
um you've listed six ways so yeah like the only next option left is like you can get your email out or something like that yeah exactly call me up yeah yeah no i mean yeah those are those are pretty good ways i definitely see them like every single day so if if an issue comes in i'll try to triage it and uh reply back and at least like sort of like get that like sort of like in a milestone and you may not see results for a while but maybe you will maybe you will so this is a call you'd love to hear those types of suggestions or feedback yeah well absolutely either improve the docs if the feature exists or put it on the on the pipeline uh if it becomes a priority
yeah and i just had like a few recent issues about docs about sometimes certain parts are confusing uh you know they don't read well i love stuff like that because like i want to know what's confusing like maybe at the time it was even confusing to me but i just you know sort of had to you know put that in um but and sometimes things need revisions just because things change in weird ways and you know the docs get stale but i definitely want to hear that and it seems like also if you're willing to like make a pr i would love that too because like i can guide the pr process you know make little changes make suggestions whatever your level of comfort is with a pr especially for things like docs because that's like easiest sort of way to like make a big impact it's just just changing text really
RStudio IDE color highlighting
um there's a quick question from slido as well so this is not gt related but when you showed the um color highlighting in the RStudio ide um yeah how do you turn that on or is it just or i guess what's that feature i think it's automatically turned on there might be an option to turn it off i think there is an option to turn it off but with mine it was by default on and where i got that was from RStudio daily release uh so if you go to dailies.rstudio.com that's where all these um you know very recent like builds of the ide live um they're pretty they're pretty stable i use them once in a while just so i can catch up on what's new uh but i really you know some of these things are great like the color thing is like a dream i never asked for it but i don't know i love it it's nice if using color is like and you do that in gt a lot so it's great to see that it's verified that you're getting it right
Combining ggplot2 and gt with patchwork
yeah cool well uh kind of earlier in the discussion um erdi had asked uh in my work i often produced a4 output and pdf uh mainly with ggplot2 content it would be nice to be able to combine ggplot2 plus gt tables in a similar way uh to how patchwork works um having the plot and the table next to it is very useful sometimes how would uh interactive gt tables be different from reactable i guess that's different i said actually topic we'll get to in a moment yeah yeah yeah but for that first one uh gt patchwork i can totally see the the appeal of like arranging plots with tables in a sort of like nice way um i think some early sort of like looking at that was done um we'll see by ellis and i believe tom as well uh so we're looking into that it seems like a difficult thing kind of like one of those high difficulty but high reward sort of like projects um although it does seem like it would be like a slam dunk if you got that in as a real feature i mean there's so many things chris but that that that is like a good one especially um you know as it relates to like our new publishing endeavors with Quarto um and i'll actually check in to see if like Quarto could do some of this as well as a not as a replacement but as a another way of like arranging like these things together um but yeah we're looking into that essentially is the short answer maybe not a very satisfying answer
Interactive tables in gt
there set it up so um yeah basically would you like interactive tables with gt there's there's been a couple questions and and at least one question in in um zoom and slido and then these as well so yeah i'm kind of curious what your thoughts are on the ability to add interactivity reactable is obviously very is already very popular for doing uh creating interactive or you know having having interactive features added to a table so yeah i'm just curious what your
thoughts are um yeah i'll say like this is like a thing we want um but we never focused on to highlight a couple big points right is search in fact my you can see my comment there is the third one um you know search and uh kind of column filters that sort of thing yeah well the great thing about reactable is that we can use that as infrastructure for gt i actually have a branch um it's not really a pr yet but it's like an experimental branch of gt that has like interactive tables and it basically uses reactable under the hood so we can apply the same sort of api things that gt has but just use reactable as the engine for producing tables
to make this work nicely we have to make sure that all the styling and all the things that you expect come through um we have to know like you know like not no but we have to figure out you know how summary rows would work inside of like this new interactive table maybe they don't work but um we want to make sure the look and feel is sort of retained but still using like you know like all the work that's been done reactable because i think it's kind of like a little bit not counterproductive but a little bit too much work to like reinvent you know like another like interactive table project just for like one feature so that's something i've been exploring and the early results are pretty good like you get all the features you get the searching you get like the filtering um you know like all that all that good stuff and you can turn them on selectively as you would with reactable uh it just you don't have to type on a bunch of reactable code you just use gt code maybe switch an option a few more things and tab options for you know switching things around and then you're pretty much there in the same place can the community help in some way or start testing things out yes yeah my first thing is to make that sort of public as a pr and make an issue that pairs with that and then just that you know like illicit comments um from the community i think that'd be great yeah um and then you know publicize that a bit so people actually know that it's being you know done um yeah yeah that'd be good i'll have that i'll have that going like this week actually no it's actually good thing testing it recently and like it's a thing that's constantly asked and you know it's a big thing but to be able to push across the finish line you just have to like you know you know get back to it and you know work on it so yeah that's great that's great uh there's another question from zoom uh is arthur still here would you like to ask you sorry you asked it uh probably at least 40 minutes ago so if i can't catch you this is what the question was i'm dropping into chat right now okay uh is arthur there by chance
Styling rows with validation rules
yes awesome hey yeah so the question is is is this so like gt has this nice way where you can kind of style um rows that may kind of defy a certain validation rule let's say um but currently it seems like one needs to you know add a new tab style per per rule are there any thoughts for making this easier like um i don't know something like dplyr dplyr across or some other way of like kind of implementing this across several like applying to several columns yeah i believe you can do that um you have one rule for how you want to style and then you have multiple columns you need to use a vector of columns or you could do a tidyselect you can use where uh you know like where is numeric for instance would be one thing um yeah let me know if that doesn't work because like my current understanding is you just supply a vector of columns or any sort of tidyselect statement uh should do it i believe if you do that the columns all have to exist uh no actually if you just include a vector they all have to exist if you're using tidyselect they don't you can use like something like begins with or and start starts with or ends with things like that
um does that answer your question yeah i think so thanks i'll tinker and come back to you if yeah if it doesn't work as expected yeah yeah it doesn't work definitely let me know because like yeah so i i there's another question that i really wanted to ask you um this is a question that came from linkedin from sean claude um and the the what the what part of the reason why i want to bug you about this is uh when you gave your talk at RStudio conf in 2019 you had a question for the audience that was this as well yeah so i think i yeah so excel output is basically the question it'd be a huge improvement i often have to produce tabular output that would be easily used usually it means excel tables so far mainly do this in python with some libraries a simple r solution would be great preferably with full control over cell numeric formatting borders merge cells replacement that sort of thing if you could do that by christmas that would be awesome
yeah i've heard this a long time ago i wasn't sure how many people would do this because there was already solutions in place for doing this but not really right like not with the api that gt has um so this may be a thing like this would definitely come way before like something like powerpoint that was also asked for um so yeah and it's not in there because you didn't ask for it exactly what type of table output are you so doc x is big i'm thinking like anything office is kind of big because like office is big so um but i'm hoping with the new doc x uh stuff that we have in things like powerpoint and excel are not too far off because they both use xml and we're using the xml basically it's open x open xml uh cogeneration to to create that word document uh nice so it might be yeah it might be close like it might align like very closely with excel as far as i know like each tag has like the name of like the office product in the front of it and then like you know it's used but i'm not sure if there's like different arrangements of the tags depending on the upper format but i want to say it's pretty close um so it may not be something that's like totally like new and like an entirely like separate project it might be like just part of like the the word or office project as it were so i'll look into that like the first part is for like investigating you know like like how much work will be like an estimating but i've heard this time and again like excel is kind of like a big thing so it's you know it's kind of impossible to ignore at this point so yeah basically i'm going to look into that as well cool we we just got a bunch of questions coming in um with four minutes left so first off are you able to go after like it'd be nice to maybe do we could do a little summary for at the hour of uh how to get in touch with you kind of go over those the kind of calls to action you might have and then uh you know whether or not those folks are able to stick around we could at least just get those questions answered so that there's a record of it um yeah so first off uh in in the video description and associated with this you kind of went over ways to get in touch with you um and so we'll share those as well i saw isabella actually shared those in zoom chat yeah um i did want to call out
Upcoming pointblank workshop and ways to reach Rich
something as well uh tomorrow right you have a workshop at r and pharma it's free it's if you if you just google r and pharma 2022 workshops you'll get a nice list of them and uh you want to add the event bite group um and can you it's not gt it's not tables can you kind of walk through what you're presenting tomorrow yeah it's a different package of work called pointblank and uh yeah totally different than gt although it does use gt to make the reporting uh the tables as it were um but it's different it's all about like validating your data like you know validation rules things like that to make sure you have correct data and it's also um concerned with data documentation so in the outputs you do you do get gt tables which is kind of nice because um i'm basically programming with gt so it is possible to like use gt as like infrastructure for generating reports so that's what that that package does so basically during that three-hour workshop i'll be going through um all sorts of things dealing with data validation and data documentation basically like making data dictionaries the work workshops closed now so i was mistaken i thought it was open uh is it going to be recorded like how would people get yeah it's going to be recorded and i do have all my workshop materials available um somewhere it's in the repo called your docs are great i've seen those yeah yeah it's in a repo called point blank uh workshop and it has like everything there i'm going to share that just here in the zoom chat and it's nice because i uh there's a rco cloud project there so you just run all the rmds it's basically an example based or yeah mostly an example based workshop i'll be running through all these things explaining things uh changing things up inviting q and a throughout um so hopefully within three hours you have some sort of like handle on how to use like the package yeah is that an RStudio package it is not it's my own sort of personal project you're an open source maniac you're just creating yeah i do some things on the side yeah yeah but yeah well just just to sum up for the hour so folks who need to leave uh are able to so thank you very much this was our inaugural pilot uh open source chat uh with our guest rich we'll get through uh as many questions as rich has time for afterwards so feel free to stick around um if you asked a question but weren't able to stick around have a look at on youtube what we'll publish this a bit later where you could see that discussion so thank you everyone for hanging out and participating and definitely reach out to rich uh regarding kind of feedback and comments and the ways that he's gone over again if you didn't catch that check out the video description and our follow-up will kind of cover out all of those ways to help make gt and open source software for data science better and just again thank you for being excited about participating in this and contributing in your own ways we really appreciate it thank you thank you had lots of fun yeah
Post-session questions
yeah cool so as uh some folks are going to be dropping off no no worries and uh i i did not double check with you how much time you have left over but maybe we could just kind of jump through as many questions as you can or just let me know yeah absolutely sweet so um nathan uh had asked a question in fact he had warned us he was going to ask a question and then ask the question so i want to make sure i get to him is nathan there by chance or did he jump off i think he jumped off
um yeah so are there uh i'm gonna i think i'm gonna copy paste it so it's the most recent question in zoom uh nathan uh are there ways to have grouped rows i mean uh when repeated rows have same characters we can merge them into one oh yeah yeah we do have that actually so we have row groups it's not well documented or exposed yet i do have some examples but essentially you do row group as column as a tab option option and then what it does is it takes the row group that's customarily at the top with the label running across and it puts it on the leftmost side in the stub and it doesn't repeat you know across multiple rows it just shows it once so that's basically like i hope that's what you expect like you just get like it shown once at the top and then all the other like rows in that group um are just don't like labeled
and steve actually had a steve rola had a suggestion as well um okay yeah do you have it do you know what it is i do yeah let me let me just drop it in the chat so some of the context i'm a little bit missing on so i may i may have missed a little bit of a context oh yeah that's great this is perfect this is showing tidyselect so you can totally do this like where is numeric where is factor uh this is great because like if you use for my currency on columns which are not numeric um it won't work so yeah basically this is like pretty sweet yeah yes i just wanted to note i'm the one since i wrote it in there yeah i use that when i know everything's numeric but any of the tidyselect i've i found work you can do contains like contain starts with ends with all of that works perfectly in Quarto that's that's typically where i've used gt yeah and the great thing about tidyselect instead of using explicit columns is it won't fail on you if it doesn't find those columns it won't like you know error if you put explicit column names an expectation is that you have all those column names in there and it will cause the stop or error so yeah tidyselect it's good stuff uh britney b has a at least at least one question i think two questions um would you be willing to ask those britney sure um so the first question is kind of like trying to get gt to be like an excel screenshot um so at my company one of the standards that they put around tables is that your table should have column letters and row numbers so that you can reference things like b5 or something like that is there a way to get that into gt tables sort of uh so you prefer to have like the like b1 at the top above a column name right yeah you could you just have to introduce like a line break and use markdown formatting for each of the column names um the trick there is how do you make a line break at all uh well at least with like um with markdown you have to use two spaces then a slash n i'm gonna write that in the chat because it's not incredibly obvious actually it's really hard to know this um see if i can write this like this so if you have that in your column name like say you have like the of course you have to generate the the the letters yourself um but it's not gonna be too bad to do that the trick is to get a line break uh to work you have to use that and then make sure you use calls label and then um use markdown like the md keyword or uh function and then it should render nicely like with a break and then like with the actual column name what about the rows because wouldn't you want the rows to be sort of a separate looking almost column yeah that's more difficult because before it was not easy to use front markdown on like the row labels uh but in a recent change to 0.8 which is yet to be released that's not possible uh you can use front up markdown on a column which is like the stub and if you don't have a stub at all same you just use front up markdown and then use the same trick here but yeah you definitely use paste to get this going or glue
brittany you also have another question and i feel that oh that that this question actually should this i feel like there should be a blog post that yeah because it's such a comment i get
this question so often and because it's so difficult to like we don't have like uh we don't have a bunch of like nice affordances for like doing little obvious things like line breaks uh and other little things like that in gt unfortunately or you know subscripts or superscripts um and you know we can't do that but markdown like at least the last thing i talked about the subscripts and superscripts but you can at least do line breaks which is very common but i don't really have that anywhere in an article i don't believe or very much it doesn't figure into the help articles too much so i think i should like try to get that in there as much as possible or try to make some other i can't think of another way of doing it but there's gotta be another way of doing it um brittany also had another question um and you had brought this up earlier but uh yeah brittany would you like to ask it or
yeah yeah i can jump in so do you have any suggestions um so i'm kind of like the resident uh our expert on my team so i'm doing a lot of things like trying to um take some of those like templates or things from word documents and like one page or templates that analysts will put together around like a thing that they did um i'm trying to incorporate that into r and i've done it with ggplot2 where you can actually put the corporate colors in there and the like fonts and things like that but is there something similar or do you have suggestions for how i could maybe build out a similar type of function but for like dt tables yeah certainly uh so just going back to this i'm going to share my screen quickly uh right here doing a bit of this would be good um but it doesn't get to the part where you actually introduce graphics to the header um which is kind of tough it's almost like you want to make like a i don't have an example unfortunately but you could put a graphic into like the header at least um just by using html and then doing something like this um this is not gonna be a full example given the time restraint we have but we can use tab header you can at least have like title and then something like html and then put in like your custom html in there which can include graphics and things like that into this part um i wish i had an example that i could just show you but this is i think this is the key if you want to put that in there that would work and it may not work in the custom theme part but maybe it would with just some tinkering so this is definitely another blog post idea or article idea i think because i kind of wish i had an easy solution for this um but i think this is like the the way to at least get into the header um and this is kind of the way to set all the different like you know colors and styles for the rest of the table so maybe to be continued more on this soon because like not incredibly obvious how to do that i do sign up to make a list of everything you've either promised or half promised so that at least at least that's hanging over you in some issue somewhere yeah yeah some things i just lose a little bit of track of um uh but i definitely want certain things to bubble up and be in my free movie again
for sure um i think we hit every question i did want to acknowledge that um erty who i think is still on uh you know would have been happy to ask his question or her question but was uh uh was a was away at the moment or had had internet issues but they're so i i as far as i could tell i think we've kind of gone through all of the the audience questions as well as the the ones from uh twitter i sort of grouped a lot of them together because there were common themes about preferred output formats or desired output formats there were sort of two sets of questions regarding interactivity which is uh just generally i would like some and then also focus mainly on search and filtering um but yeah like i this is pretty much it unless folks would like to ask something additional feel free to just open up your mic or or pose it in in chat but otherwise i think we're i think we're all good yeah and again be not afraid to like post issues i love issues like i said like they they sort of steer me into doing things like into priorities essentially so yeah definitely open an issue if you can and you may have got this earlier because i came in a little bit late but um one of the things that i've noticed in googling it it seemed like there's some other people mentioned as well with pdf output for wide tables it doesn't shrink it down like it is on html if you're in pdf yeah that's right um it could be like i'm not using like the right long table uh options for that there might be something already in long table which is what we standardized on and i think what a lot of like um um like software that generates tables like pandoc has standardized on for tables um it could be just there's so many things we could be doing in in the long table context but maybe we're just not getting there yet at least we split across tables we don't repeat columns half the time so that's an area of work for latex output that's you know even coming before like styling of okay those do you have an issue on that yet or should is that something that i should follow up with as well because i i steve i think asked in twitter as well i think if i'm remembering correctly i had an issue if there's already an issue board it up okay you know make some noise on the issue if it totally like affects your your workflow yeah makes sense thanks welcome
they they sort of steer me into doing things like into priorities essentially so yeah definitely open an issue if you can
unless anyone else yeah thank you so much um for participating really appreciate this pilot in two weeks we're going to have another one where greg lynn who's the package maintainer of reactable is going to be joining us uh for the same format um so looking hopefully y'all could join uh looking forward to participating in that and well that's looking forward just to be clear thank you so much rich for doing all this with us and sharing all this really appreciate it yeah
