
Christophe Dervieux | Business Reports with R Markdown | RStudio
Business Reports with R Markdown Presentation by Christophe Dervieux As you share your analysis with business stakeholders across the company, how do you create the look and feel that they expect? This talk will cover theming of reports to fit with graphical guidelines: what can be done already, how that works with Powerpoint and Word, pagedown as another way to generate well-designed PDFs, and also how we plan to improve. Christophe is a software engineer at RStudio. With an engineering background in economics and energy, he discovered R as an analyst then became a passionate R-admin supporting all R users and usage in his previous company. Longtime contributor for open-source R packages, he now works with Yihui to make the publication and reproducibility ecosystem with R Markdown better. Christophe's repo is here: https://github.com/cderv/meetup-2021-rmd-business-report Slides are here: https://meetup-rmd-style-business-report.meetup-rmd-style-business-report.netlify.app/
image: thumbnail.jpg
Transcript#
This transcript was generated automatically and may contain errors.
Okay. So, today, we'll talk about Business Reports with R Markdown, what's the name of the meetup, and we will see how to better theme reports.
So, that was already a quick introduction, but I'm from France, so it's late here, it's a light diminish, it's normal for me. And so, I'm working as software engineer at RStudio in the R Markdown team, so we see you here on every R Markdown-related package.
So, what are we talking today? I put myself in, like, previously, I worked in an organization before joining RStudio, I was working in industry, and often the question was, so, I work in an organization, I have some guidelines, protocols, things like that, and I would like to use them with my R Markdown document, because by default, R Markdown will give me the same document as everyone else. So, how does that work? Can I do that with R Markdown?
And so, today, I'll try to cover that, I will cover a lot of grounds, so there will be a lot of things, it may not be as, it may not go as into details as some of you may want, but hopefully, you will learn some stuff.
How R Markdown rendering works
So, first, the thing to know is, I wanted to remind you about R Markdown and what happens when it renders. Hopefully, everyone knows about R Markdown here at the meetup, but a quick reminder, R Markdown is a tool to mix text, code, and render to some outputs, and several outputs using the same source. So, you may know this illustration by Alison Horst, and it illustrates the way that sometimes R Markdown can appear like magic. You just write a text file, and you get a styled output, HTML, a PDF, or even a Word document, and so, it can be magic, but really, it's perceived magic, and you need to understand what is under the hood if you want to customize the default behavior, and styling is part of that.
So, what happens when it renders? It's a workflow of different tools. You are writing an RMD file, and the first tool that will work is NitR. NitR is an R package that will execute the code in your RMD document to put that into a standard text MD document, so a Markdown text file, and so, it will execute the code and keep the source code and the result depending on the option you will do, and so, it allows to programmatically create some content in a Markdown document, and after that, it will be Pandoc. Pandoc, it's an external tool, a universal converter, and this is the tool that will allow to convert to PDF, to HTML, to Office document, and a lot of other formats, and RMD is the R package that will organize the work of those different tools.
So, this is magic. This can be magic because you are working only with RMD, and you don't know what happens, but when you want to style an output, usually, you need to know what will be your output, so if you want to style HTML, it's not the same thing as styling PDF, and it's not the same thing as styling Office documents, so it's why I wanted to remind of that because sometimes it can be tricky. There is a lot of things that you can do that are generic in our Markdown document, but when you want to do specific things for an output, sometimes you need to know about new skills and new specific stuff from this output, so let's talk about style now.
Styling HTML output with CSS
The first format that I want to talk about is HTML output, and for HTML output, styling goes through CSS, so CSS means Cascading Style Sheet. Some of you may know that already. This is a web technology, and it's paired with HTML. HTML is the code that structure your web page, and this is what you write in the text file, and so with R Markdown, you are writing Markdown syntax plus R code, and Pandoc will transform that HTML for you, but if you want to style your HTML page, and then you want to change how it lays out on the screen, you need to use CSS. If you open an HTML file, you will see that it is just text, and what you see in the browser, it's a mix of HTML, then CSS, and JavaScript, so styling HTML output will require more or less CSS skills, so we'll see that it can be, you will need a lot of CSS skills or just a few CSS skills depending on what you want to style, so if you want to use that in your organization, you will need to use CSS. Either your organization is already using CSS, and they can prevent you directly with some CSS snippet, but otherwise, you will need to learn a bit and adjust from your guideline, so how to use CSS with R Markdown documents.
CSS looks like that, so it's a language where you define some rules, and you set some value, some values, and NitR has a CSS engine, so you can put that directly into your R Markdown document without any external file, so it's pretty simple to do, and it's useful for prototyping or quickly iterating or changing a value in documents, and so I use that often when doing demos or or those type of documents, so here, this code means that I want to apply a specific style, so a blue box with text center into it on a component that will have a class MyBox on the document, and you will see later how it looks like, and I want, and the second rule is I want that any bold text inside this box to be also blue, so the same color as my border, so this is how I can style differently than the default, because this style is definitely not default in RMD documents.
So you could use CSS, but as you see, I'm repeating the, I'm repeating the blue color, that could be the color of my organization, or I'm repeating some, duplicating some rules in the document, and so can I do that more efficiently, like a programming language, like I can do function in R, and so in fact, you can do that using a web tool, which is called Sass, that exists since a long time, but that recently has been available in R from a package with the same name, so the Sass package, so first, what is Sass? Sass is a CSS extension language that allows to create rules and variables, for example, so it's pretty useful to use it for variables, but you can do a lot of things and very advanced stuff using function or even operation in your stylesheet, so if you know about CSS already, you know it can be, it needs to be pretty simple, just key values associated, but with this extension language, you can do some operation inside your stylesheet.
So what does it look like? This was my CSS. To produce this CSS, I can write this SCSS file, so you see it's a bit different, and the main advantage, and why it is useful even for beginners using CSS, is that you can use variables, so usually in an organization, when you have guidelines, you have some main color, secondary colors, and you have like a set of three to five colors that you should use in your document, and using these tools, you can put those values into variables and then use those variables in different places for your stylesheet, like if you want one color to be used for all your headers, plus some border and another color to be used for strong text, for example, you can change that, and so this SCSS code looks like the CSS, but it's using variables, like it's starting with a dollar, and this will produce the same, this CSS and so you can use that also directly into NitR and into RMD document, because NitR supports the SCSS endline, and so writing that into a chunk will apply the style for you, you don't have to know anything about compiling a SCSS document and building the CSS file, you just have to write that in the document, and it will work, and this works in R through the sass R package, and the support is now built-in into RMD.
There is a NitR engine, but it's now built-in also into RMD, so I put the link to the package on the website, where you will find a lot of information, and what does it mean to be built-in? It means that the CSS field that you may know about in HTML document, you can pass directly a SCSS file, a sass file, and RMD, using the sass package, will do everything for you, so that the style applies in the document, so this could be a great way to have a sim file that you can use across different outputs, or a sim file that you can exchange between colleagues, or maybe your organization already has some sass file that you can use, so using this technology will make it easier, because you can use variables, you can use some function and rules, so it surely needs new skills, if you don't know about that, but if you plan to customize reports regularly, because you need to provide report every week, every month, and it's not just one shot, and if you have time to learn new skills, it's a great way to do that.
Custom blocks and Bootstrap theming
The fact is, you can also apply custom scenes to your content, this is something that maybe a few people know about, but there is a special syntax inside R Markdown, that is powered by Pandoc, that allows you to create custom blocks for example, here what I've put, and you see, you may recognize the blue box that I put the css before, by creating this syntax in my rmd file, so using the three columns, then the class name, I will create a component that has the class my box, and if you remember the css I had before, I had something that applied on any component with this class, and so R Markdown using Pandoc will transform this to html, you don't have to write the html yourself, and the css that you have written will apply, and so you'll get the blue box with the centered contents.
So with this, you see that you can apply css on already existing components on your page, but you also can customize specific parts on the content, and you can also do that using an inline component, using another syntax that you see in the first chunk, which is called bracketed span, where you can put the class in specific elements, and by doing that, so I put an example with another css, I apply a background on some text just using the syntax in my document, so you can customize a lot of things using this technique, but it can be still a bit complicating if you don't know css, and you are not like at ease with those technologies, and you can go like further and simpler with Bootstrap. In the past two years, our studio has developed a new package called BSlib, which is tools to customize Bootstrap, and Bootstrap is used in a lot of our formats and a lot of our tools, so it was developed by the Shiny team, by Carson Sievert, and this will allow you to customize documents more easily, because you don't have to know css or sass.
This is now supported in R Markdown, it will be supported in Flex Dashboard, the new formats from Bootstrap that you may know about, which is called BS4book, is built on Bootstrap for using a BSlib package, and it's also supported in DT to style stable, and in Shiny, and in the next packaged version, so the aim for us is to use this tool to provide a consistent seeming system across our different formats that are using the Bootstrap web library.
R Markdown still doesn't use BSlib by default, but you can activate it pretty easily using the seam yaml key, as you are seeing in the example, and so you may already know the Bootstrap team, like I've put an example with the Cerulean team here, seam here, so this will activate the use of BSlib, and activating BSlib will allow to customize the seam using only yaml header, so this is pretty interesting. In later version of R Markdown, maybe next version of the one after that, we will make BSlib the default in R Markdown, either with Bootstrap 3 as today, or maybe we'll use the BSlib default, which is currently Bootstrap 4, and will be 5 pretty soon.
So I won't go into details on how that works, but this is what I can put in my yaml header, so I'm not writing any css file, I'm not writing any css chunk, or things like that, I'm putting everything into my yaml header, but I can change colors on specific elements of my web page, so those variables are not random, they are the ones supported in Bootstrap, so you have tables in the BSlib package on the website, where you can find all the variables you can customize, so it requires a bit of reading documentation, and know about that, but usually you want to modify some of those values, like the primary or secondary color, to change the main color of the page, because everything else will be kind of calculated, but if you want to change pretty specific elements, you can, so here in the example, I'm changing the main color, the primary and the secondary color, I'm styling specifically the block code border to yellow, I'm creating a variable for light blue, that I will apply on the inline code color, and on the border of my code blocks, I'm also setting the width of the border to increasing the width, and changing the color for warnings and info block in my document, and I'm also increasing the heading font weight, and changing the font on my document, so you can do a lot of things, and hopefully using one of those, or several of those values, you will be able to create, and to tweak the document to be coherent with your organization guideline, and using that in another document would be as easy as copy pasting the yaml header, or storing that into a file, because you can put those things into a specific yaml file, shared across your document, it's our marketing features.
using that in another document would be as easy as copy pasting the yaml header, or storing that into a file, because you can put those things into a specific yaml file, shared across your document, it's our marketing features.
And so doing that in my yaml will render this kind of document, so you can see, so this is a basic document, it's not, I've put the links, when you will have links to presentation, you will be able to download the rmd source, and the html output, and so you see that the header has a bigger font weight, that I get the blue color on my code chunks, the primary color is applied on the link, I get the yellow vertical rules for the block loads, and also I change color for the warnings, and I created a text using warnings, and creating a specific box, because one advantage of using bootstrap to style documents, is that since bootstrap 4, and it's why bslib is really useful to styling documents, there is a lot of specific classes, and specific tools, that you will find in bootstrap documentation, that you will be able to use in your document.
Office documents: Word and PowerPoint
So the html part was a bit long, because this is the main document that usually people do with rmarkdown, and you will find some useful resources in those different websites, what is going on, and what already exists. So in the remaining time, we will go more quickly on office documents, and then pdf documents, because in organization, often there is still word and powerpoint documents that are used, and it's interesting to know that you can customize those, when you are creating these with rmarkdown. So customizing a powerpoint presentation, or word document, is as easy as providing a reference doc, and so to create a template, this reference document, there is one way, and it's my advice if you want to try it, is that you should render the document without providing any reference doc. This will output a powerpoint presentation, or a word document, and you save this document as a template, and then you can modify this reference document to change the style, to customize the color, to customize some of the things that Word and Office let you customize, and then you can use this document as a reference doc. This is one way of doing it, obviously you can use your own templates if you have that, but you need the mechanism that this is powered by Pandoc, and so the mechanism relies on Office style.
So here is a quick screenshot of what it means to modify a style in Office. I hope this is big enough, but this relies really on the Office style. So if you style your Word document by just selecting the text, and changing the color of the text, for example, color of the font, and things like that, it's not really styling. Styling in Office is having a name style apply on a paragraph, and apply on the text. There are two styles at the same time. So here, this is an example of modifying the paragraph style for my second level heading. So the first step is to place my cursor into a second level heading, and open the style pane. And the style pane, this is on the left, will have, you'll see that the blue box show what is selected. So this is the heading two style currently, and I will right click on this and modify. And by doing that, there will be a modify style pane, and here I will be able to change the color, or add border, or do or do things like that. And then I can click OK, save my template, and use it in the document. And what will happen when you will re-render using this template, is that the heading two styles that is put on second level header will be the one that you have in your template. So this is the way you can style Dockex and PowerPoint output. And the same way that with HTML, you are able to apply custom time on specific part, you can use the same type of syntax for Word and PowerPoint, using a special attribute called custom style. So by doing that, I'm applying on the left, I'm applying a special highlight box custom style to my text that I can tweak in my templates, so that it applies.
So you will be able to download the RMD source and the template and see how the results look like, but it will be a style with a colored box and some text in the middle. So I put link to documentation. This is powered by Pandoc, and this is the main document, this is the main limitation with this styling, is that we are limited by the feature that Pandoc supports for styling office documents. So not everything can be customized, sometimes it can be pretty limited, it depends on what your organization is using, if it's using a very complex template, or if it's just some guidelines on what your document should look like. Know that we are trying to improve this, we worked this summer with Pandoc to improve the PowerPoint templating mechanism, so it will become easier in the next version when we are doing something with Pandoc, it needs to be released in Pandoc, then it needs to be available in the RStudio IDE, then in RMD, so that you can access it, but soon it will be easier.
But unfortunately, styling office documents is not really easy, through Pandoc or not, because one must know about the office style system, and from my previous experience in my previous organization, I know it's not, not everyone knows that, and sometimes people send you templates that are really like dummy documents to fill in, and not really template to use as style, because they just put some headers in color and define custom style in the document, but if you are using simple customizations, that should work, if you are using complex one, maybe not. So know, if you are an AV office user, know that there are other tools in the R community, mainly the office-verse by David Goel, with the officer package and the office-done package, so officer is about manipulating office documents from R, and office-done is is using RMD to use officer to create PowerPoint and Word presentations, so you can be interested by those packages.
PDF output with pagedown
And lastly, about PDF documents, if you really want that, because you need to produce some report and send them in PDF, it's often not easy, because producing PDF, the main usage is using LaTeX, and so as I said, when you want to style an output, you need to style it by the technology that is used to create it, so PDF will be created by LaTeX, and you need to use LaTeX to style the document, so there is some specific LaTeX packages that you can use, sometimes it could be helpful if you already played with articles package, or if you've already written LaTeX, you know about that, if you don't, maybe it's not as important to invest in it, because there is a new way to create PDF, it is through HTML, and the good news is that you can use CSS in that case, so you can use the same technology to produce the HTML and to produce the PDF, and there is two solutions to create PDFs for HTML, the first one is kind of simple one, is printing the document as is, it means like if you are using Chrome for example, there is a good printing function, but the drawback is that it will print the document as you see on the screen, so usually a web page is linear, it can be very long, and it can be not suited to be printed on A4 formats or paginated documents, but the second solution is to format and style the HTML specifically for printing a document to PDF or to a paginated format using what is called page media CSS, and the good news is that there is an R package for that, which is called pagedown, I won't give much example, I just wanted to share that with you in case you don't know about it.
pagedown will allow you to create paginated HTML, and it brings basically, it brings a page.js JavaScript library to R, which is used to create paginated content, so by paginated I mean that when you will open the HTML on the screen, it will look like some pages that you can see, and the pages is defined by margin, is defined by header, footer, a page number usually, a running header, something like that, so you can really create paginated content using HTML, and if you are interested, I would suggest that you look at the talk by Yui Hsieh on RStudio Conf 2019, which was where pagedown was announced.
As an example, I wanted to show you this, so what you can see on the left is the resulting document that you can create using pagedown, so this document is created using PageReport, which is a community package developed by Thomas Roland and David Case, and they wanted to simplify the use of pagedown through templates, because pagedown is really the core tools to customize, but there is some templates included in it, but if you want to make a template specific to your organization that looks like that, it could be a good amount of work, and what they did is provide templates where you can change some parts of the template, look at the colors, the fonts, the cover, or the logo, so it can be a good way to start with this and as examples to see how you can create such templates.
Summary and what's coming
That was a lot of information, so we've seen how to customize HTML output using different technology, we've seen how to use templates, mainly with Office outputs, we've seen that you can create custom parts in your document using margin syntax, specific margin syntax, and we've seen that PDF can also be customized for your organization if needed. What you need to remember is that this is just the beginning, for some time there was no easy solution, CSS was the only one for HTML, recently it's easier through the use of SAS and BSLib, and hopefully it will be easier in the years to come, because we are working on a better HTML seeming system in the R Markdown team and in RStudio, also mainly because BSLib will be only useful if you are using a format that uses bootstrap, but we want to make the seeming system using YAML or any other mechanism, a simple mechanism, so that you can use the same scene across different types of outputs, so we are working on that, still thinking about it, but we will continue to improve based on your feedbacks and based on what we know and try to contribute to Pandoc also, because we think that seeming report is something really important, so that you can differentiate from others, and usually in corporate world it's important to stick with guidelines and things like that, so thank you.
we think that seeming report is something really important, so that you can differentiate from others, and usually in corporate world it's important to stick with guidelines and things like that.
Q&A
Awesome, thank you so much Christophe, I'm seeing quite a few questions that are coming in both the Zoom chat and on Slido, so just a reminder to everyone if you do have questions, if you don't mind just using the Slido link it will help us organize them all. But let me head over to the Slido and start to ask some of the most upvoted questions there, and one that came in was can params be used to reference variables for PowerPoint outputs?
Sorry can you, I'm not seeing the question. So one of the questions was can params or parameters be used to reference variables for PowerPoint outputs?
You can use parameters for PowerPoint outputs, but I don't think it will help you style specifically the PowerPoint output, because you will need to use a template to style the outputs. The parameter will allow you to modify some content or to dynamically include or choose what to put in your documents.
Thank you, and just a note to everyone, if it's your question that is asked and you want to jump in and add any additional context, feel free to unmute yourself as well. The second upvoted question was how far can styling go before it is considered not much better than chart junk? The part of, like really the aim of all this, and it's why it was, I presented that in the business report with R Markdown, it was the topic of the of the meetup, is usually you need to style when you need to stick with guidelines, or you need to stick with an organization, or you want to differentiate from other. But don't style just for styling or to make things fancy. It can be like chart indeed, but sometimes it's important that you can change the color, or you can communicate using your organization guidelines, because otherwise you may not be able to communicate using R Markdown output, just because you don't have, you don't follow style guide, so.
So you can go pretty far, especially with the BS Lib customization, but I would suggest to stay with the main guidelines, like the main color, the main fonts, and things like that, and maybe some specific tweaks, but if you start to change every element, it would look like not appropriate.
Thank you. And I see Jay Krogman asked on the Zoom chat, is there a clean way to call a custom CSS, or does it have to be within a chunk in the local directory?
Yeah, you can, yeah, go ahead. Oh, I was just going to add, so like, the current way that I've been solving that is like, A, created a package, and inside that package, inside the inst file, I just add like a custom CSS file, so whenever you like, go to say like, okay, well, let me pull down this report template, whatever it is, it has that custom CSS within that special file, right? Is there a better way to call that in your YAML header to where you're going to like, either a Git repo, and then you're just calling that custom CSS, or does it always have to be in the local directory? Or inside a chunk?
No, the CSS arguments support a URL, so you can, you can pass a URL to the CSS, CSS file that we store online. I think I've been making life painful for myself, though. Thank you.
You can do that, but it means that the user will need internet connectivity to build the slide, so it depends on the constraint, and if you want to share templates, you can use package and the hints, but you can also use project templates, or documents template in the package, so this is something that is supported through the RD, the ID, and the R Markdown draft function, where you can put the R and D template with local resource into it, and when the user wants to use the template, it will copy everything locally so that it works, so we are using that in a lot of the package when you are like, opening a new, a new, creating a new R Markdown document, for example, it's, it's copying a template from the installed package to the local folder. The other way of doing that is to have a chunk where you download the CSS that you have shared online, and put that locally, like you can do anything into a chunk, you can do anything, and hide that, so usually when I'm using resource, the first time I'm downloading, I'm downloading it, and after that, it's local, so that I don't download every time I'm rendering.
Thank you. Thank you. I just want to take a quick break in the Q&A to let you know about a survey that the RStudio team is launching to get feedback from people like you all, so I just want to pass it over to Nick Warren to share that as well.
Thanks, Rachel, and great presentation, Christophe. Hi, everyone, my name is Nick Warren, and I do product design here at RStudio. We want to invite you to join us in completing a brief user research survey related to how you leverage RMarkdown. The goal of this survey is to better understand your use cases and workflows, and to help us validate our hypotheses around some new features we're developing. The survey has nine questions and takes about two minutes to complete, and we'll be open for about 24 hours from the end of the meetup. I'm going to post the link to the survey in the chat now. Hopefully you can see that okay, and I'll personally be reading your responses, and I'm looking forward to hearing what you have to say. Also, huge shout out to Kelly O'Brien and the rest of the RStudio team for their awesome work with all of this. Thanks a lot.
Thanks so much, Nick. Okay, so going back over to some of the questions in Slido, I see there's anonymous question on how to adjust the HTML page margin and break in multiple pages. It can. You can. So, page margin and page break is really that we have for page-initiated HTML, so pagedown is definitely an answer if you need to do specific customization, mainly because a web page doesn't really have the concept of page margin, just a main page with content in it. So, page break is something that you can do, and if you look at the Armagon documentation, you will see there is a special comment like slash page break that you can use to create a page break, but if you want to have really page margin with some content in the margin, the tools to use would be pagedown.
Thank you very much, and quick question about the GitHub link you shared. I see a few comments in the chat that people were getting a 404 error. Okay, yeah. Still private. I need to make that open.
I saw the question about the RMD document I used, for example. There is two examples that I included as documents, so you will have the link, and it will be in the published presentation. So, when the link will be shared, you will be able to download the RMD and the output of what I presented.
Thank you. Artemio asked a question, which was on slide 17 that you showed, where you had the custom YAML header. Is this savable as an R Markdown template, or is it easier to save with a custom CSS file or other method?
You can save that. The YAML header, if you are using always the same, you can definitely put that into an RMD template, and you would use the same template for each of your reports. But with R Markdown, you can also put the output key in an external file, which would be underscore output.yaml. And if you have that in the same directory as your RMD document, and you don't have the output key in your RMD document, this one will be used. You can use this external file in your different documents. So, if you are using Bootstrap and you want to use this YAML key, this would be a way to go. But it's also, we are not completely satisfied with the system, so it's why we are working and thinking about also something else to share across documents. Also, because this can only be used in Bootstrap-based HTML documents, and not like, for example, you wouldn't be able to use that in Schrodinger implementation.
Thank you, Christophe. John, I see you asked a question, can we create custom engines for R Markdown, and is there documentation or tips on it? It's an opportunity question, because it does not really, it has nothing to do specifically with styling and theming, but you can create a custom engine for NitR. So, it's not really for R Markdown, unless you are talking about a custom output format, but it would be for NitR, you can create custom engine that would be a, like, documentation is quite sparse on that, because it's quite advanced, and I think it would be in the NitR book, but the NitR book was the first book from UA, and it's not free, so you will need to buy it, I guess, and, but it's documented in the website, documentation for NitR in the website of NitR, and you can find some example in the package, and that would be the best documentation to look at the custom engine inside NitR package.
Thank you. I'm not sure if this was covered in a previous answer, but on that topic of creating new pages, how can you make a new page or section or landscape page using Word templates for R Markdown?
Yeah, this is a tricky question. I'm not sure you can. This is part of the limitation from Pandoc, because Pandoc doesn't support that, so I will need to check and try, because maybe they have evolved on that, but if you have these kind of tweaks, the officer package and affiliate, the office-verse packages would be the way to go, because you would be able to modify the layout of the page, but I don't think you can using R Markdown, which is using Pandoc, so this is part of the current limitation.
Thank you. The next question is, do you have any elaborate Bootstrap 4 examples to reference?
The main example for HTML document or for any type of output, you would find the main example would be the BS4 book format, which is used in now most of the books from Adly, so you can look at the Shiny book, the R package book, even maybe the ggplot book is using that, and there are a lot of books now using BS4 book, so you can see how this looks like and how people have customized the BS4 book format to their style, and you can also find example on the BSC package package done website and the SAS package on website. There are not so much on R Markdown only, because we think that it was not really documented, so the presentation was part of making that better, and so hopefully there will be more examples by you or anyone else creating that, and we'll definitely update everything if we switch to using Bootstrap 4 as a default for R Markdown, which is not currently the case.
Thank you. Julian asked in the Zoom chat, how is the integration of R Markdown with Jupyter Notebook, or integration of R Markdown in general, I think. R Markdown is mainly about, like, it's a similar technology as Jupyter, so you can't really use R Markdown with Jupyter, and you can't really use Jupyter with R Markdown, but you can use R and Python in R Markdown, and you can use R and Python in Jupyter, so there is a function to convert between the two. It's kind of experimental, but it's working, and there are some tools, I think, in the Python ecosystem, like Jupytex, will allow you to convert between formats, but R Markdown won't. Maybe I didn't understand the question, but R Markdown and Jupyter are a bit different, but they are doing the same thing, and RStudio is currently working on making this a bit better at the higher level, so something similar to R Markdown, but not directly R Markdown, so that it can be used not only by other users in R, but it's still fresh, so you will see that appear in maybe a few months, I think.
So, Ryan asked on Zoom, is CSS styling used for, I can never say, share engine presentations?
You can, yeah, yeah. CSS, the CSS method and the SAS tooling using the CSS format can be used with any HTML web tool, any HTML web format, so sharingan is just using a specific library called Remark.js, but it will produce HTML, so you can use CSS to style a sharingan presentation, and you can do pretty advanced stuff. You will be able to look at the source code of the presentation I've made. I don't know if it's the best example, because I'm tweaking a lot of things, but I'm definitely using CSS to add style and some utility class and other tools, but you can use any web tools with sharingan, so, yes, CSS styling is used for sharingan. You won't be able to use the YAML styling, because it's used by BSLib only and Bootstrap, so sharingan is okay.
Next question is, how can we generate equation number and label in Word documents, like in LaTeX?
This is a feature that you can find in the package. The referencing of equation and the labeling of equation can be found in the Bookdone package, and either, if you want to use a book format, but you can also, there is a format called Word underscore documents 2, which will have the feature, so best thing to do is to go to the Bookdone book documentation, and you will find the part about Word documents.
And while you're sharing that, too, one question that I'd love to ask to the audience, too, is someone asked, are there some good books for CSS and Sass?
I mean, I'm interested, also. Basically, I learned CSS on the go while trying to customize, like, I'm not a web developer at first. As it was said in my background, I'm an engineer in the first place, and so I went through code using R, and I learned, like, by doing mainly, and for CSS and Sass, at the end, the documentation that the Shiny team made and Sass was really useful, so you can also start there, and it's possible there is some interesting information on the recent Shiny book, different Shiny book. There is several Shiny books that are going out, and often, there is part about styling and maybe part about CSS, so, yeah. But if you have some good books, I'm interested, also.
Thank you. A few questions left. I see Nico, you just asked in the Zoom chat, can you embed HTML output with Plotly graphs in an email?
I don't really know for sure. This would be something to try with the Blastula package. This is a package that allows to write RMD and embed it to image, but the difficult part is that if you want to embed something into an email, everything needs to be contained into the email, and Plotly is pretty big, so I don't know if this is possible, but really, I don't know the answer, so it could be from a colleague of mine, but you should, like, try with the Blastula package, and if it doesn't work, look into the issue or ask the question in the community, and Rich will surely answer to you.
Aaron, I see you had some feedback there on most email servers will not display JavaScript. Yeah. Yeah, that's my experience. I think the suggestion of using Blastula to do a JPEG is you can attach an HTML file, but somebody will have to open a browser, which is hard on their phone. The right way to do that is probably to link to something elsewhere, and then use a JPEG via Blastula to get stuff captured.
Another question. We have maybe time for three more. What would be the right best practices to follow while creating business reports in PowerPoint using R Markdown?
You can do that using R Markdown. You need to keep a simple report because there is not a lot of customization that you can do. Usually, when you are doing a PowerPoint slide in PowerPoint manually, you would do a lot of tweaks, eventually, placeholders, and so on, but you don't have to do a PowerPoint slide in PowerPoint manually. You would do a lot of tweaks, eventually, place components in different places. When you are using a tool like R Markdown to create those, you will need to keep a fixed layout on things, like have three to four template slides, like one main slide, main layout, or two-part layout, things like that, and stay with that in the whole presentation, and try to keep it simple. Basically, this is also something that we are interested in feedback from because it may not be as easy to do that. We have improved during the summer, as I said, working with someone from the Pandoc team, so it won't work as best as it should right now, but it will hopefully come soon into that. The best practice would be keep it simple in your slide, but it's something that is not just for PowerPoint output, I guess.
Thank you, Christophe. There are two other questions left around PDFs. So, one is, to print PDFs using pagedown, you need to use a Chromium-based browser. Can you print multiple dynamic reports using PDF print, using Shiny?
Yeah, you can print PDF using pagedown with any tool that allows you to print HTML and that supports the page media rules. You need to use a Chromium-based browser because Chromium has a function and has an API that allows us to dynamically call a print on documents. So, in pagedown, you have a function that is called Chrome underscore print that will basically open Chrome or Edge, load the document, and then print this. But if you have other technology, like the previous technology was PhantomJS, but it's deprecated now, but there are surely other, I guess you can do that. And from Shiny, you would be able to do that for dynamic report, but you need to have the external tool available. So, you need to have Chromium or you need to have this tool available in the Shiny app or in the server so that you can call them. But you can print dynamically HTML to PDF using those kind of tools. So, you should be able to do that in the Shiny app also. Depends after on which server you are deploying your application.
Okay. And on a similar thought, someone just asked, will PDF produce via CSS and PageJS give me the same level of control as a LaTeX template?
It depends how much you know about LaTeX, I guess. If someone is using LaTeX from like 10 years or more, he will know a lot about how to use LaTeX template and style. And I think it can do a lot of things and PageJS and CSS can be a hard step for such person. But if you don't know LaTeX yet, maybe more interested to invest into CSS and PageJS because it could be more toward the future. And HTML, you can do a lot of things and it's really powerful, but it could rely on a lot of high skill. But I see the same for LaTeX. Like I know only basic about LaTeX and I won't be, I know I'm not able to make a LaTeX template and I think I will be able to make a HTML template. So, I would say yes, you can do that. But PageJS is kind of new and it's still new for the web and LaTeX is here since a very long time and is made for doing PDF and doing papers and things like that. So, I guess you can do more using LaTeX now if you know about it and if it works well for you.
Thank you so much. And there's one last question that came in from the Zoom chat is how do you handle special characters in a French document?
They should work. Like I'm French, so I could easily debug if there is an issue. So, don't hesitate to post on one of the repo. But Armagnan is working using, so this kind of special character I've seen is called encoding stuff and Armag

