 We're going to make a report out of it. So the way we do that is with our markdown, which is just a flavor of a markdown that is specifically for our. And I will go into more detail on what exactly that means. So again, as every, I'm not sure why this gets, but yeah, as every single one of these presentations have been, this is Creative Commons. So feel free to use it, remix it with attribution at any point in time in the future. Okay, so moving on, what we'll be doing today is just setting up a brand new markdown file and then talking about the different ways that you can output reports. So we'll be making them in HTML and PDF by the end of tomorrow. Then we'll talk about loading data into our markdown, which is very similar to what you've already done, likewise with libraries. And then today we'll just finish off with how we actually take the code we wrote today and put it in an our markdown format without any errors and then that'll be it. So a nice, easy, I hope, rehashing of what we've done so far. Yeah, and again, feel free to ask questions at any point in time on the Slack and either Greg or Lauren or myself will take a moment to answer them. Okay, so our markdown documents will let us convert all the analysis, like I've said before, into something that's nicely formatted and I'll show you in a second what I actually mean as I'm saying that over and over again. So today we'll just go over a little bit of syntax and then tomorrow you'll see that once we've kind of set up all the code in what I'm going to explain in a second are called our chunks, there's actually very little left to do to make it nicely formatted and human readable and even publishable down the line. So this is what is going to happen today. We're going to take a document from our markdown and I'll go over in a second how to generate that just within our studio. And then we're going to look at how to display as a PDF and as an HTML document. And HTML documents, you know, are just really versatile. Just everything you see on the web eventually is rendered as HTML. And so by creating that particular report type what you're able to do is you're then able to put it maybe on your lab's website or you're able to view it in like a little bit more computer friendly format than PDFs sometimes are. And so it's just really great for any sort of like screen type interaction that you want to have with your reports down the line. And PDFs are also useful for all the other reasons that PDFs have been useful until now. Okay, so knitting is just the technical term that I'm going to be repeating a lot. So I wanted to just clarify that I'm not saying anything particularly magic here. It just means that it renders a document. So it takes all the code and then knits it or, you know, formats it and compiles it into the HTML and PDF views that you're looking at here. So when the button on your studio says knit to HTML it'll open this HTML viewer which you can then open in your browser with this button over here. And then it'll just show in Chrome or in Firefox whatever tool you're using. And then if you knit to PDF, then it'll just save in the same directory as the directory that you're currently working in and show you this for a markdown file. And the text that's here, that's all auto-generated every time you create an R markdown file in our studio. So it's nice because you never have to memorize any part of the structure that I'm presenting now. It's always just given to you, I'd like a little that they like boost your memory. So you remember how to format it. And the goal here really is to take analysis that you've already done and very easily convert it. And that's the intention with these kinds of documents. So if you know here, a few things we're going to learn by the end of tomorrow are things like how we can make nicely formatted headers. How we can add the date of the publishing and our author name to reports. You can see there's like all kinds of different fonts and styles. And also there's all kinds of different views for your code. So this is an output, for example, from the workhouse function, I believe. And here is a plot that we've output. So you can really control in a fine grained way how something is seen in the end product. Okay, so we're going to take a second now and this is going to be the only practical component for the next like probably 10 minutes or so and I'm going to be just with you. And we're just going to make an arm work down file. And this is what we're going to be working on the rest of today and also tomorrow. So you're going to start by going up to your file drop down over here in the top left corner, I believe for most of your screens at least. And then under new file, you'll see this arm markdown option. And when you click on it, you'll see this dialogue panel. So you can just call it whatever. I called it in my first markdown report. The author name should be pre-populated with your name, which just comes from your machine, I believe. And then you'll select if it's not already selected the HTML option, just because it's the most versatile. And further down the line, we'll talk about how to render any format you want at any point in time. So you're not confined by the option that you select here right now. So I'm just going to demonstrate really quickly and then we'll take a minute to do it on our own, just file and then select the arm work down option. And then as I've shown you, I've already have something actually fine. I can name it, this doesn't have to be unique actually, because all it will populate is this top section of your report. It won't actually name the file itself. So my first markdown report, and then HTML is already selected. And I go, okay, this is what you'll see. So as I've shown you before, it already comes pre-populated with quite a bit of text. And we'll go over in a second exactly what each of these sections mean. So if you could all just press yes when you've done that and it works for you, and then we can move on. Nice. I think we've reached form, I believe. If anybody's having any trouble if you could just do a quick type in the, oh okay, yes. That's right. We didn't mention this before the break, which we had to bench to. That's all right. I can keep lecturing, and then it should install the packages on its own, but at minimum you'll need our markdown and tiny tech. Lauren, if you could just paste in the Slack, the commands for that, just so that we don't waste too much time on it. But for whoever's having trouble rendering the files or creating them, this is just what you'll run in the console, and then it'll prepare it for you. The prompt. I think we'll automatically download the packages that you need to specify them. That's what it did for me. Yeah, it should be a pretty painless process. Okay, so in order to actually knit or render this file, you'll go to this knit button up here, and that should be at the top of a specifically our markdown file. This button here will it'll first prompt you to save this. So we'll save it as, you know, as RMD1, for example, and then as it knits, it will open up this browser window, and then you'll be able to see what this actually looks like. So as you can see, even like with pretty minimal playing around, it's already a nice presentation of information and code. And here I'll highlight, again, there are several options. So although you selected HTML when you created the file, you actually have the options here to switch between PDF and Word at will. And then as long as you have the packages like pre-installed in your machine, it will just render, you know, without any further input from you. And then if you don't, it'll just prompt you first to install them and then you can continue. Okay, and then the document outline is one other thing I'll point out. On the top right corner, you'll have this little button with a bunch of lines on it that are supposed to be like lined with code. This will show you, depending on the headers that you've included in your unwritten file, the outline of your document. So the same way that you see a document outline like in Google Docs, for example, this does the same thing. And this is just to ensure easy navigation through what can sometimes be a pretty lengthy file. So now we'll go through how to load data. And again, this is very similar to what we did before. I'll kind of go through the anatomy of this first before we do that. As you can see the actual command, very similar to what we've done so far today. So the first thing that I'll talk about is this YAML header. And YAML is an acronym, which is kind of has a fairly not meaningful meaning, which just says YAML in a markup language. Just basically means that this specifies the metadata. It's not a full language and doesn't have like too many specifications it can actually let you do. It's just like a very structured set of rules that you can include at the top of your markdown file. And then it'll control the type of output as we will later see. It'll also control whether you have a table of contents or pagination or references in your document. And so for now, you don't have to do it. And today we probably won't touch it again. Hi, Gabby, a quick question. Does the date have a, does it have a, what about if you did a year, month, day instead of month, day, year? I believe it does nothing. Like it won't yell at you. We can play around with this. Okay. I believe it's just a string. It's just a string. Okay, perfect. Okay. Sorry for the vlog. Yes, you can kind of put in whatever you'd like in that. This part is pretty not finicky. And generally speaking, if you accidentally make a mistake here and write a command that doesn't exist, it'll just maybe give you a warning in the console, but it won't actually, very rarely, will it actually stop you rendering a file? Which, you know, is both a problem sometimes, but sometimes it's just nice to not have to worry about. Okay. The next thing I'll talk about is just some more terminology. This section is called a code chunk. And anytime you see these three ticks, followed by a curly brace and the letter R, that's a code chunk. So that means that just our code will go there. So any code from the analysis or plotting or loading data that we've done so far today, we'll go into one of these by the end of today. And then the third is just this run button. So you can either highlight all the code in a chunk and press command or control enter and run something, as you can see at the bottom here, or you can just press this play button and it'll do the exact same thing. And it'll just stop at the end of the code chunk. So the bottom three ticks. And as you can see from the highlighting in RStudio, it actually delineates quite nicely where your code chunk is and where the text is. And so what that means is like, you can actually just run your analysis straight in our markdown file. And then as you work through things, it'll just generate the report for you automatically. So quick pumping, just a little bit more detail on that. It'll start with three ticks, the curly brace and the R, a really important detail. And we'll close with the three ticks here. Then aggregate data is just the name that I gave the code chunk. So code chunks can't have spaces, the same way variable names can't have spaces. And we just use them mostly to keep track of where we are and to allow easy maintainability. There are more fancy ways that you can do things with our markdown. For example, create a fully functional, like multi-page website where the code chunks can then be reusable. We won't go into that today or tomorrow, but they do have purpose beyond just being nice names. I like them just because it's compulsively organized. And then number three is a nice way for us to organize how much output we actually include in our report. So with our markdown, we can actually control which code chunks will show the console output. So all of the feedback that you get from running a function and which code chunks won't. So in what cases is this useful? In the case where you're loading, for example, just your data frame, you don't really want the output from the console for that because that's not really like interesting or meaningful information to the reader. In cases like, for example, the table functions or plotting functions, you would want that output because that's what the function does. It creates output that is visual and informative. And so in that case, you would include true, which I believe is also the default. So really you don't only have to specify false when you don't want that output. So this is just more details on that. Echo false means that we won't see the code chunks themselves. So in cases where we're not really interested in showing the code, we would do echo false. In cases where we want to show the code, but we don't want to show the output of the code, we would use include equals false. And these are things that you kind of go back in reference again and again. So don't worry too much about memorizing them. But in cases where this is useful, it would be things that you want to run in the background. So again, loading data, maybe you don't want to show the name of the data frame that you're using. In that case, you would put it in a code chunk that is under the echo false command. And then you won't have to see it when you're rendering it. So an example of that would be here. And then when we knit the document, you'll note that echo false meant that the plotting command never showed up. All you saw was the plot itself. And so it just created like a nice clean visual of the image itself and then not much beyond that. So, which then- Sorry, sorry to interrupt you again. The purpose of this document is to be open and to share what it is you did so that people can reproduce it, correct? Or to create something that's publication quality or you can also move beyond PDFs and HTMLs and create actual PowerPoint slides. Yeah, but that said, but the purpose is to create something that will allow scientists to do reproducible science, right? And so maybe, I guess, so with respect to your last example, so I'm being facetious a little bit, but I'm at open science freak on this side. It's my day job. And so I guess to show how you're loading data and what the format of that data is, you could load dummy data, I guess, and show that and then say for your data, it will be whatever your data is. I appreciate you don't want to show your data, but you want to show how you loaded data. So I guess is that a include false sort of type statement? Yeah, exactly. So you won't see the output, but you'll see the code itself. And sometimes when you're just writing, you know, you should code that could be helpful. And then you can put a dummy file name in your document that you want to share. So it's not to give away what your file name is in real life, for example. Yeah, that's the word. Because even if it errors out, it wouldn't actually be a concern because you wouldn't ever see the output of that. No, exactly. But you also, you want to show people how what it looks like with dummy data. And so, you know, just take an example, you're loading a SAM file. And so you don't want to actually put the actual number of a SAM file you're putting into your example. But this is, you want to load a SAM file and you want to see what a SAM file process through this workflow looks like. Yeah, I think in that case, it would really, yeah, so you could then kind of play around with a combination of these echo and include chunks. You would want to include the code that shows the dummy data file, but then you'd want to suppress the output from every chunk that uses the real SAM file. Real data, yeah, yeah, yeah. You could do a bunch of clever stuff with that. But like in the past life, for example, I did like a couple just reports that included visualizations where the client themselves weren't particularly interested in the code that I used. They were just interested in like the takeaway. So then that was a nice way to create something that's very readable, but then like doesn't add too much overhead work beyond the actual R script. So that's like a good way to do it. Yeah, but let's say your client was a nasty reviewer of a scientific journal, of an open access scientific journal that wanted to see your, our markdown project sort of file before he accepted the publication of the paper. And so you'd want to provide as much information that was open to this said reviewer and to the said readership of this publication. For sure. Yeah, then you'd want to be clever about which code you're revealing. Yes. For all nature goals, this is what you should do. Yes. Okay, thank you. It's great. Okay, so, well, very nice. We're making good time. Our first exercise, which is like the last thing that we'll do today is we're just going to take all of the code from our previous exercises with Lauren and we're going to try that into a functional or a markdown file. So what do I actually mean by that? All I want is for there to be kind of like logical chunking of our commands in these R chunks. And I want it to run without error. So don't fuss too much about what code should be included or not included until you have that running. All we'll actually do is we're going to take... So this is the code from Lauren. What I'll do is, for example, I'll copy this. You can see, actually. Yeah, can you copy code? We ran because we didn't run that. Or sorry. Yeah, there we go. So I'm going to copy, for example, this. Which you're in. It just has the names, the dimensions and structure of the example data to .github. And I'm going to just straight up erase all of the given code after this YAML header. I'm going to create a code chunk. So three texts are code chunk one. You can name it something more meaningful, but just for the sake of today, you can click and dirty about it and you're going to put this in here. Comments will work the same way as they do in regular art. You can also paste them outside of the code chunk. And this will actually give you text that names the code chunk in the actual report. And so if I have df2, yeah. So one thing to note is that I have df2 already loaded, not you'll want to run, which all of you should, because we've all been here today. You can just run this command as well. And then that will work the same way it does. Otherwise you can type that before you need it. So, oh, this is, I think, in just like a different directory. So we can be more explicit about it. Over here. And then as you can see, it outputs a bunch of different stuff, which means that when it nits the file, I'll put the same thing. So if I knit it, you'll see the same thing that I pasted in, just like in the R Markdown format. And it'll look a bit messy today. Tomorrow we're going to go through all the different fine tune controls that will make it very nice. And then at the very end, what it will look like. Is a very nice reports with a bunch of different types of visualizations and tables and so on. So this, for example, is the PDF version of that. So a nice table of contents, a bunch of headers that are numbered. So we can keep track of them very easily. A table that's like centered and captioned. And then results from all the different analyses that we've done up until now. So that's what we're working towards. So for today, just creating co-chunks. And with that, I'm just going to review to it. And then it'll be on Slack. And so we'll learn it, Greg, to kind of help me through that. And that's it. Gabby, can I ask a clarifying question? In the past, I think I found that I needed my whole script in my markdown file. The whole script has to run without errors for it to knit. Is that true? Yeah. And I think a workflow tip I'll give having made this answer key is I'll start from the top and I will take in just a single bit of code at a time and then run it bit by bit without error before actually, yeah. So rather than just copying and pasting all the code from today, I would just do it like biological sections. So by one type of analysis, by one type of plot, for example, and then make sure those separate sections run before I actually knit it. Awesome, thank you. Yeah, but as you can see here, the finished document, because I've made so many different headers, will actually have like a nice document skeleton. So this is what the main header will look like and then it'll indent as the headers becomes smaller and smaller or more front-end. Does anybody have any questions at this point? I can... What do you suggest to... to... Thanks, Tim, there. Yeah, so why don't we do a couple together, actually? I think that's probably going to be best to get us started. So here, I've just set the working directory and I've read the table that we've already read today. And again, you can run them line by line and then it'll allow you to see them. Sometimes, code chunks are kind of finicky in that they'll run just like all together. Rather than row by row, but this sometimes helps you debug along the way. So now you see that this code chunk runs fine. Once you have this, I would move on to creating another one. So just you would write out three ticks and curly breaks again with R and then we'd name it code chunk too, for example. And then close it off over here. We're just going to go back here and go into the next. I like to call them logical groupings, but really just it can be an arbitrary number of lines. So long as they run all together without error, we're going to copy them and paste them just here within the code chunk. And then to check our work, we're just going to press play and then we're going to see that it runs without error. Then we're just going to continue on. And as we build this file, we port over all this code. We see that our final report grows with the output. Okay. And that's it for today. And then tomorrow we're kind of going to talk about how to make tables look nicer, how to give figures, captions, and titles, and so on. Is that label code chunk and code chunk too? Does that come, like, does that get knit or is that just sort of for reference when you're writing it? It's just for reference when you're writing it. So that won't be like a section label or something. No. The section labels will come from the actual text that you put ahead of the code chunk, which can just be written the way you would write, like normal English text in like any other work processing location. So here is some text that describes my code. The comment portion won't appear as like text labels then. No, it's within the chunk. Exactly. It will appear as a comment within the code chunk itself. There's no way to, like, highlight a portion and be like make this a code chunk in the same way that you would highlight a portion and turn that into a comment, right? I don't believe so. Yeah, unfortunately this part is a bit tedious, which is kind of why I wanted it to be the last thing that we did today. And the only thing, so it's not too heavy a day, more will be quite a bit heavy. Yeah, Lambert right now, that's exactly what you want to happen. We're going to make it look a lot nicer and more readable tomorrow, but for now, I just want all the code that we've written today to work in our markdown form and nothing. Nalia, do you mind just moving all that code that you have outside the chunk, inside the chunk and then seeing if that resolves your error? Kind of, it won't be a PDF, it will probably be a .html, but if it doesn't open up on its own as a pop-up, it should just be in the same directory that you've created your markdown form. Gabby, you can't set your working directory within markdown, right? The chunks, they won't let you do it. They won't let you do it persistently, but it shouldn't throw in error. Lamont, did this command work for you before, earlier in the day? Yeah, I had no problems with it before. Do I need it? Sorry, go ahead. Do I need it? No, generally, if you're already working in the same directory where the data is, you really don't have to worry about it as much. And if it's really giving you a lot of trouble, you can just move all of the location mapping that you have in set working directory into the retable call itself, like just before the file name, and that will run just as well. So generally, set working directory is not the command that you would want to use in markdown, you would want to use one of the NIDR, like built-in functions for setting a directory, because set working directory will set it just for the code chunk. And so it'll yell at you and give you a bunch of different errors when you try to do that. I have a different error when I remove it and just run the second line for the second chunk. It could be that your markdown file is just in a different location than the data. What I would do is I would just copy the desktop slash intro to R, like Apple string, and then put it in the same location as either string in the retable call. So instead of this, I would just do this command. So Emma, it seems that your R code chunk is not closed properly. Can you try to just start a new line with just the ticks underneath it and see if that results your issue? What's some attempt to do zero-length variable name? I think that, since this is your first code chunk, I don't think you can actually, so you'd want to start at the very beginning of the script that we ran through earlier today. But not just that working directory. No, if you have the data file itself already loaded, then you don't really need to run it again. But you would want to start from here just to make sure that you have the same variables in your environment that you had before. One other thing, Emma, when you tried to run this, did you press the play button on the side or did you just like select all and then press command enter like you did with your scripts? I just did command enter just like randomly. Right, so that's kind of an important thing to mention. But if you press command, so if you just do like command A and then press command enter, well, you should generally yell at you. But yeah, there we go. Attempt to use zero-length variable name. It just means that our Reddit and try to run it as just like a general R script, which obviously it's not because it's got all these different texts and code names and YAML and all that stuff. So you'd actually want to either knit it or run each chunk independently with the play button. So the workflow here is just a tad different than it would be for just a pure script. Yeah. I feel like I just don't know what's happening. Why don't we start from the top in terms of just the workflow? So let's start a whole new file. And we'll go from there. So we have our report and we're going to make it in HTML, which we've already done successfully. We have this YAML that just has the title and a bunch of different strings that don't do much other than tell us that the output is an HTML document. Then here is just like some pre-populated code, which shows here is just plain text. And over here between the ticks is our code. So these are the names of the code chunks so that when we send it to someone to look at or to contribute to, we can be specific about how we refer to it. For now, that's really the only purpose that these code chunk names have. Include false just means that we won't see the output when we actually run it in the knitted file. And that's helpful to us because this is just some setup code that we don't really want to see in a report that shows like our analysis, for example. Will it work if you don't put include false? For sure. It'll just include it so we can do that. So this is what it would look like in it. So first we have to save it. So I'm going to put it here. So we can do the same data after this runs. And then this actually doesn't have any output. So perhaps this was a bad example, but let's give it something to work with. It will work though. It's like that thing, that particular command, the include true or include false, won't give you an error either way. All it'll do is it'll copy what is happening in the console into the actual document that is being rendered. So it'll take a command that's a bit noisy here. In our other file, we have all of this stuff, right? This output's like a whole table, which shows like the names in the data frame. So the names of the columns, it shows what happens when you run head, which is the first five rows or six rows rather. And then we have the dimensions and the structure. So if we a snip now, what we see is all of that output line file in perhaps in some cases, that's a bit noisy for us because we ran those demands so that we want to know them, but we wouldn't necessarily want like this kind of unstructured list to show up in our report. So what I'm going to do is I'm going to separate the names out into a different code chunk. And then I'm going to suppress the output for it. I'm going to do is close this one and then start a new one or we're going to call it code chunk 1.5, again, because the name doesn't matter much to us. And then I'm going to include false over here. What actually happened is the output from names will no longer be shown. So when I run names of data frame two, it outputs this list. When I knit this new file with include equals false, what will happen is that whole code chunk will disappear. So we won't even see it. So it ran in the background when the file was knit, but the output from it and the code itself doesn't show up. If instead we wrote echo equals false, what would happen is this. So the code chunk didn't show up, but the output of it did. And so for today, this is kind of something that's nice to know. We're going to it in a lot more detail tomorrow as we did the exercise. Just so no one feels lost. I know, what are you seeing when you press knit? Is it just that the HTML doesn't finish loading? Yeah, it means our markdown tab where the console is, it just sort of keeps spinning. Interesting. If you try to just restart our studio, sometimes it lives, but I'm not sure. Maybe Greg, do you want to take Hannah to a breakout room to kind of see what's happening? Thank you. So if you want to share this with a collaborator, it depends on what part you want to share. If you just want to share the results from the analysis, you can just knit it and send them the actual knit document and that's all they would need to see. So I would send them just the PDF from what I did before or just the HTML and then that would be enough. If you want them to contribute to it, then yeah, you would have to give them the data source as well, the same way that you would with like a regular R script. Okay, so we have Christina Sturridge, she's and Salman, did you end up being able to run it? I see that you have the line with teams that actually commented out. So was that you trying to resolve it? Yeah, that's commented out after seeing the error. I don't know why, because the first chunk, it ran well, but then I got into second chunk and I thought it's issue with the team. I don't know, it's with the library or package. I was splitting up the chunks. I find that it just kind of helps you get a more specific error message that way. Coming in. Tried to split up the chunks before the theme set. So until I guess the last two got wrote this. And I just want to continuously add to it. That's what you get. I find sometimes. Hi, so sorry. So you are not able to go and break out rooms. You should be, Greg and. So first of all, we're not able to send people. I'm allowed now, as soon as Rashad came back. Oh yeah. Uh-huh. So I'll leave it like this. I'll just close my camera and mic. I want to leave the Zoom. Don't leave us, Rashad. If anything's lacking me. Okay. Thank you. We will. Okay. So Nagla, it actually, if it ran once, then it means that the HTML is fine. If you want to try to run, like render it as a PDF, you're going to have to first install retouch, which Lauren had pasted the command for a bit earlier today. I'm really sorry about this. I meant to give you the command before we started the section. I need to have a say in. So. So I need the code, the command to download like let X, right? Yeah. Okay. Okay. I think my mind is fried. Okay. That's why I didn't want too much to do before 6.15 today. I really just wanted all of you to try to get things into code chunks and have them like render as an HTML. And that's entirely it. And like if you got to that point today, then we're all done. And feel free to like head out and be with your families. Okay. We'll be a bit more involved and more detailed, but really for today, all we want is like, what does the file itself look like and how do we like copy and paste code into chunks that run? And there was a comment, a question by Carmen. So if you want to share this with, I mean, it depends if your collaborator has similar data, then they can run your script on their data, right? But if you want them to reproduce or verify or you want to share your data, then you do have to share your data as well. And they have to load it up in R and then run the way to the analysis. I think just to clarify here is this is a report that you don't run any code on. So if someone wants to run their data through something, share a script because then you can run the script. This is going to be a PDF. You can't run this at all. It's just reporting what's been done. And so it explains what you did, right? Yeah, exactly. It just explains what you've done. It doesn't allow someone to run what you've done. Only a script would do that. Yeah. And then for that, you would share the script. You would share the data. And so just to be in the open-mindedness of R and RStudio and Markdown and all of those things, that's, it's a way of data sharing. It's a way of explaining what you did. But like Lauren just said, the R Markdown document doesn't share that much in a way. It explains what you did, but it doesn't share the data. It doesn't share the script. You have to do that separately. If someone could look at it and know, okay, that's what they did, like an understand. Yeah. Sure. Yeah. Yeah. And they would say, and then maybe build a collaboration. So, oh, this is really interesting. I'd like to do that with my data. Can we work together and can you share your script and so forth? Yeah. Okay. Yeah. So this is a really great starting off point for, if you've done something like quite complex and you want to feature it like on your labs website, as a blog post or just like a way to have like very lightweight scientific communication. This is a great way to like take little pieces of your big script and just feature them to show people how to do a certain aspect of your analysis. Hannah, is it still compiling for you? Yeah. Interesting. Gabby, did you know about this error? It just never stops compiling the markdown file. So she goes to knit and then it just keeps kind of running. Yeah. I asked her to quit R and then start up again. Okay. Yeah, I wasn't sure. But it didn't, that's a tough one. And I didn't fix it for you? I think she's still doing that. Yeah, I know. Oh, I see, okay. I paired the actual R commands down to almost nothing and it was still setting the directory. I'm sorry, maybe we duplicated effort on that. Sorry. No worries, yeah. I'm glad no one had like a wiser, or not glad, but I was really like, I've got all I can do. I can only make it simple and so simple, I suppose. Yeah. Yeah, I've never come across with a problem like that. I'm just looking out now to see if I can stop overflowing. So some of you, oh, sorry, go ahead, Gabby. I was just wondering if the, or Greg or Hannah, if the code chunks themselves ran independently, like before the knitting, or if that was also vinging. Yeah. Yeah, it was running, it would run. It just wouldn't knit. Yep. And it's just a long running knit. Yeah. Hannah, when you are back up again on our studio, can you try installing the Arm or Gump package again? Like maybe you just had an error in installation and that's kind of where the issue was. Sorry, which package? So you would just want to run this. So install packages and then Arm and Gump. And this is the time that they reset this to our session. It'll kind of feed all your environment variables. Okay, so at the top here, we have our YAML, what they call metadata. So what this means is just like, these are the set of settings that you're going to give your file. So here, and I will repeat this, when we get to the appropriate slide, you have the types of output that you want to render. So you have your HTML document, you have your PDF document, and then some other settings I'll talk about. And then on top, you have places where you can specify the title of your file, the date that it will have been published at, and then your name as the author. Over here, we talked about this code chunk. It's called setup and we can name it whatever we want, but they have to be unique within a document, the individual names. So we write false here, so that we don't include the output from the code within our file. And then we have our libraries, as we know to include them from when we did earlier lessons. And then this is how we read the data frame. So very similar to the workflow that we've done so far. And then we need it just up here, the knit button, because I have these two lines, HTML document, PDF document, it will output both. And so this is an example of the HTML file. So over here, you see the table of contents, which I'll teach you in a minute how to specify. And it kind of gives us a way to traverse our file. And this is what it will look like. And then likewise, you have your PDF, which will look very similar, but in kind of a more traditional publication format. All right, so with that refresher, I'm going to move on to the client. Okay, so the first thing you may have noticed is that there's all different kinds of what our markdown files picks that help us format the text in our markdown file in different ways. So one of them is this single tick. And if you notice in Slack, sometimes the text that I write in the answers to you guys is like, a bit orange and it has this console font. And if you want to do something similar to signify a variable name, for example, in your report, that's exactly how you would use it here. So the Slack comment box actually recognizes a lot of markdown syntax and so do other places around the web. So it's kind of nice because though this is a particular R flavor of a markdown, our markdown itself is used across a lot of different platforms. Then we have this single tick with the letter R in front of it before this, which looks like a very small R command. So the function mean called on data frame two and the age column. And this is how you would add inline code into your paragraphs. So if you call this within a piece of text that you're writing in markdown, what will actually be output is this number over here which is equivalent to the mean age that's in the data frame. And so it's very helpful when you're talking about results in like a paragraph format so that you don't have to use the code itself as the only way to spend yourself you can use also just embedded or inline code. And then the last one is a code chunk which you're all familiar with. And that's when you have the three ticks on the front and then the curly brace, the letter R, the name of the code chunk and then echo or include depending on what you want the code chunk to do. Okay, so now we're going to talk a bit about readability upgrades. So the first thing that I wanted to talk about are the output types. So when you specify HTML document and the PDF documents under output here, you'll see that when you press knit it'll actually create both file types at once. And there are many more options to create many different other file types like slides that come in both PowerPoint and more default formats that are like more Mac friendly. Yes, that's something that you're interested in. And also and then also Word documents. So it can actually put out a dot doc for example which then you can continue to edit just Microsoft. And this isn't something that you'd ever be expected to know off the top of your head. And, you know, Michael and Lauren and Greg I'm sure really don't know much beyond the things that we use day to day. But at the end of this lecture I will give you links for cheat sheets and references where you can find this information over and over again. And again, like Google, you know, every November's best friend. Okay, so moving on, the next thing to note is this number of sections which, sorry, number underscore sections. And if you select true on this in both PDF and HTML documents, it will allow you to number the sections in your markdown. So what this actually looks like is if you've noticed in PDF, for example, we have, and here we have section one, section two, section three and then 3.1. And then under investigating the data frame this is numbered section one. And so if you would like these numberings to exist rather than just have the header on its own without the numbering, that's kind of how you go about satisfying that. And then as you add onto your markdown document that will update automatically. And then the last thing is the TOC, which is table of content and the depth of the table of contents. So table of contents true is just how you would turn on this particular feature. And it's the same for both PDF documents and 4.8. And then when you select TOC underscore depth two, all that will do is it will specify in the table of contents how many levels you want to have as a navigation. So it's kind of a good selection generally speaking and it'll just be like the next level. And from this point, I'm just going to pause to give you all a chance to add this to the markdown file that you had yesterday. So at the very top where you have your existing YAML all you'll do is you'll add this text. You're ready, just select yes or no, depending on what you're having to choose. How do we create a new McDonald's file? So you want to open up the one that you've created. I think I overwrote the stuff that was there yesterday. It's fine. In that case, you can just go here to file and then under new file, you'll select our markdown. Oh yeah. And then you just specify the title and press okay. And markdown, let me just move that over here. Okay, nice. I'm seeing some difference, but we can find. Okay, I'll give you all maybe another half a minute and then we'll move on. And again, there'll be time at the end to catch up this, you didn't quite get there. Okay. So the next thing we'll talk about are different ways we can format our text. So you can choose to write plain text in your markdown documents and this will just render as a regular paragraph. But there are many more options that you can choose from. And as you can see here, this is exactly the type of syntax that you'd want to use outside of the code chunks for you to be able to render each one of these header levels and like outside and bolded text. So one thing to note is our markdown is really picky about new lines. So after each one of these lines, you'd want to very deliberately press enter or add two spaces after the end of each of these text lines so that the next line renders appropriately. And I'll repeat this again and have a reference when we get to the exercise. And then here is how we would order lists. And lists can be made in many different ways depending on what is appropriate for the text that you're trying to render. So you have unordered and then you have ordered or mixed lists. And how you would start this is you just like add a little dash at the beginning of your line and then again, two spaces or enter at the end. And then if you want to nest it, what you would want to do is you'd want to add four spaces before the start of your dash. And so when you press knit, our markdown will note that there are four spaces exactly between the start of the line and the start of your dash and it will indent the list item. And then we'll also change the list marker so that when people read it, they can see that it's like a nested subject. You can also do the same thing with numbered lists and also you can have a mixed type of list. So here we have two as the marker or the numbering of the item and then inside you have an unordered nested item. So now we're just going to do a quick practice. Gabby. Yeah. Sorry to interrupt. If, can you check on Slack? There's some students that are getting errors about not having latex installed and I don't want them to get too far behind so I don't have the quickest way to get. Yeah. I'm not sure everything is working. I see. Okay. Yeah. Can I just not do the PDF like that? That's an easy way to avoid it. And then just output HTML. What you can do for now is you can just knit to HTML exclusively. So like that here. So yeah, over here you would just not include these options. And then when we have a break for the exercise we can kind of talk about that. We can install like a lightweight version. You can install TinyTech, which shouldn't take too long. It's just in our package, but just in the interest of not falling behind. For now just delete this section of your code and knit it. And then I'll open up the participants panel and. Yeah. And I just added two on the Slack. Installed up packages TinyTech also may make it possible. I think. But if that's not working too, yeah, just cut the PDF. Gabby, do you think you could specify what the text you're talking about? It's outside a chunk, right? So when you're talking about text this is all stuff that's written not in a chunk. And then the chunk is just containing code, right? Exactly. Yeah. So in the chunk you'd only have code or comments on the code. The way that we had so far. And then outside the chunks you would just have either plain text or this syntax that we just talked about. So here I have like all the different headers and the italicized and bolded text that I mentioned. Here we have all the different list types. And then a plus sign is just another way to do the same kind of marker. And then over here is what I have for our exercise. So this is just a combination of all the different texts that we learned and then the headers and the list for keys. And when you knit it, what will actually happen is, all right, she's open to her unit file, you'll get this. So this is what header one will look like. This is header two, header three and then these are all the different stylings of the things that we'd mentioned up and going out. Wonderful, thank you. So the back to the exercise text. Once you have this working, if you could just give me a quick yes. And if you're having issues, if you could just give me a quick no or just unmute yourself and ask the question, that's all fine. Sorry, I'm not sure what we need to do now. Yeah, so you're going to copy the code that's in here. Yeah. Markdown file. And then you're going to knit it to see what this actually looks like when the file is knit. Oh, okay. Okay, nice. We have a yes. Just give it another minute. Moving on, we're going to talk now about how to insert tables into our Markdown. So what you may have noticed yesterday, if you managed to get your Markdown file running with the existing script, is that tables don't really render super nicely or perhaps not even at all. And that's because with our Markdown, inside the chunks, what you would want is you'd want to use this knitR function called table. And knitR is just the knitting compiler, I guess. So what it will do is like, it'll look at all your code chunks and then it'll just render it in the format that you specified in that top bit of setup. And this is just something that you kind of need to keep in the back of your head. So whenever you have a table or a data frame that you'd like to display in like this nicely formatted sort of way, you would want to just wrap the entire table function with table. So you'd have this knitR and then two colons, then table and then inside we have your table object. And this can be either a table as you've prepared before or it could just be a data frame. And then the last bit here is the caption that you can set. This is just an argument of the table function, which will add, it's funny because it's actually more of a title, it will add this bit of text above your table so that you can name it whatever you'd like. And so at this point I'm just going to pause and give all of you a chance to try this. So in case you did manage to port your code from yesterday all you'd want to do is you'd want to copy the table commands from the script from yesterday or earlier today. And you just want to wrap knitR around each of these table calls within a single chunk and that should do it. Okay, yes, Christina. So there is actually a distinction here that's perhaps important to make and that's that these texts are not actually single quotations but rather they're actual tick marks. And the way you'd find them is they're usually kind of to the left of your one key of the top of your keyboard. They look like this rather than a single quotation which is flat. So they're going to be like a little bit angled to the left and that's what we'll recognize. So it's the same way that you'd open a code chunk. You want to use those. Yeah, Lauren, those are right. So they'll render differently on a PDF versus an HTML and it just depends on your screen size. So at the bottom here I have screenshots from what it would look like as a PDF. And on an HTML they usually render just a tiny bit differently. Okay, so shoot me a yes if you've managed to kind of get these working. Nice. I like seeing a check mark. Okay, so we're going to just do the same workflow that we did yesterday. Oh, the way this will look is you're going to go to the markdown file that you just opened up. And as you can see over here, you have what we call a code chunk. So the way is you would just type three ticks like that then curly. I'll handle that. Okay. Yeah, and then just type R and then name of code chunk. So the name can be anything you'd like. They just can't repeat within a single file. And then you type three ticks like that to code chunk. And then in here, you'd want to type all your code. So in this case, all you really have to do is go to the file that we're working on yesterday and earlier today. And for now, all we're doing is we're taking these and just copying them into an existing code chunk. Then we're going back and wrapping them up in this function. So you'll take, whoops. So you'll want to take knit R and then two colons and table and then just wrap it around that table object. So you'll just do an opening bracket at the start of the table object and a closing bracket at the end. And what this will do is it'll render the table like really nicely for you and kind of center it on the page. Okay, can you put your screen for a second on? There, so you would look like this. So you just type knit R and then two colons and the function is called cable. Then you can highlight the rest of the line and then just type an opening bracket and that will wrap, so to speak, the code that you have in an opening parenthesis and a closing parenthesis. And then this, I called it. Should you have it read in the data on the first code chunk? Is that? Yeah, you, oh gosh, right. Yeah, but if you do have it in your environment, it should work. Oh, okay, okay. At least running it within our studio frame. Like when you knit it, it might give you a bit of trouble. Okay. When you're just running it like chunk by chunk, it should work, yeah, this is one of those things that kind of a bit of a caveat with our markdown in that some functions don't render great within our studio itself and you do have to knit them to actually make them work. So if you do get this like difference in argument links, for example, it might just be that you need to knit it to actually see it in action. So Diego, oh Diego, I see what the problem is. On line 31, your caption is outside of the actual cable function. So you would want it to be right in here. So the way that would look is just within the same cable call. It's just another argument for that very same question. Right, yeah. So when I do that, it gives me like an X on the side and it says there's an unexpected comma. I'll send a screenshot of what I'm talking about. Yeah, I think it might be because you're putting the comma after the double bracket. So you want to put it after the first bracket. Okay, yeah, okay, I get that. Yeah, let me know if that works. So Christina, you might have an issue just with Latex itself, in which case maybe try first to see if it works if you just take out the PDF section of your file and then try to render it just as an HTML. Okay, so I think we're going to move on. And again, there'll be more time in reference to kind of touch up if you're not quite there yet. So the next bit is a bit hairy than we've already gotten perhaps and that's working with plot. So this part I think is like the most ad hoc you could possibly get in programming. Like it really depends on how big your plots are, what their margins are, how much data you have, what the text size is and those, all of those things play a factor. But what you can do to make them fit in nicely within your reports is you can set figure width and figure height within the code chunk. And what this will do is it will set that particular width and height for the code chunk that has your plots. So here I set it to 10 and four because that's what worked best with my machine. And then I think that should work. If it renders it in a way that looks kind of funky or it's a bit too wide for your screen then you can play around with the width. The height was just like how much space it actually takes on the page. So sometimes it will force the next bit of text to skip to the next page in which case you'd want to decrease the height. So you'd really just want to play around with this until it looks the way you want it to. The other thing you can do is you can have separate code chunks for different plots. So in my case, when I plotted all three of them together it forced one of them to the next page. And so it kind of made for a not very continuous reading experience. So I just split them up and that managed to kind of sort out the spacing issue. So I'm sure a lot of you have similar problems with like Word for example where you kind of have to play around with a figure and resize it until it fits the way you'd like. And this is very much the same kind of thing. These are just tips for how you would go about fixing those kinds of errors when they occur. Yeah, so I'm just going to talk through a bunch of these. Types of techniques and then we're going to go to the exercise at the end. And so we have enough time to give everyone to do that. Okay, so the next thing you can do is a bit more code focused and that you can actually change the limits of your plot. So if you recall, our old plot had space from zero to 40 on the y-axis here. And so when I first rendered it or knit it, it pushed the legend kind of out of the way until I couldn't see it anymore. And that's just the way that our managed like an enterprise. What I did instead is I gave it a little bit more space. So I made the limits of the plot from zero to 45 instead. It's just like a tiny bit of extra space up top over here. And that allowed me to add the legend in a way that I liked. Another space saving strategy is to change your legend to change your legend's location. So in my case, it was rendered kind of like half off of the margins of the figure. So I moved it to the very top, the very beginning. So the left-most side at the 45. So the second number is just the y coordinate of where your legend will start. So here you specify that the top left corner, I suppose, of the legend margins in base R. And then the last thing that you can do is you can change your legend from a vertical orientation, which is the default to a horizontal one that has two columns. And that's just the end call argument at the end over here. So if you just pop that into your existing legend code, it'll just orient it in this row wise way and it'll fit very nicely in what is generally, or what is otherwise a kind of small, tight figure. And then this is an example where everything works right. I just wanted to show you that it's not always such a headache. So in this case, what was kind of a bit of perhaps a mission to set up actually ended up being quite simple. So this is just an example of how code you've already written can be plopped in pretty nicely a lot of the times in our markdown. And this is, I want to reiterate, this is the general case. Like I really chosen examples that need a lot of tinkering with to make work, but generally speaking, it is just meant for you to be able to port fairly easily from your analysis to a presentable format. Yeah. And so this is why you'd actually add a caption. So again, the code here is very much the same ggplot code that you'd already written yesterday. There's no difference. The only difference with this code chunk is that we have our figure caption. So we've now learned three different settings that we can add to our code chunk that will control the way that our figures are rendered. The first is figure width. The second is figure height. And the last is figure caption. So fig dot and what you'd want to hear is you just want to use paste. And then a string that describes your figure. And that will render it the way this renders below in a PDF as a caption. And that's it in terms of the things that I wanted to cover. What I want to give you now is a chance to go through these slides on your own for the next, let's say, 20 minutes or so. And then just really play around with the plots, give them captions, give them headings, make your tables nicely formatted and then try to render them in HTML and PDF and see what that looks like. And Lauren and Greg and I will be here to answer questions. And I will... So the links to these slides is on the website and I can pop a link to that in the Slack in just a minute. Once you're done with playing around with your code and you're kind of comfortable with our markdown, the next thing you're going to do is you're going to try to actually change the data source in your our markdown file. And I'll pop the link to that as well, but Lauren has prepared a second data source for us, which instructor looks exactly like the data frame too that we've worked with today and on the latter half of yesterday. It just has updated groups. And so the goal here is to see whether or not your analysis has changed after you've changed the data source. And then just compare and contrast the two data sources and see how your data has impacted your findings. So with that, does anybody have any questions? One more thing I will add is at the end of these slides, I have a few links to the our markdown cheat sheet and the reference guide. And these, every time you work with our markdown, they're absolute lifesavers. So they'll have the exact commands that you'd want for any sort of like specifics that you want to include in your report. I encourage you to look at them as you kind of go through these extra slides to get familiarized with what the resources look like out there. I'm just going to send you the link from the... Lauren, do you have the link from the course website handy so you can just pop down in the chat? Yeah, the course website link? Yeah, just to the slides. Carmen, just link the slides as well. Awesome, thank you so much, Carmen. And it's pinned, it's there. And please refer to the website because we have made the material. And then Gaby, are you going to go over this once we... So we're going to take 20 minutes and kind of work on our markdown files and then you'll go, okay, great. And I will also post the answers at the end of today. So if you don't get all the way to a result that you're happy with, you can always take a look at it this evening. Gabrielle, can you take this few minutes to add the source to the GitHub link to the GitHub page now? So it's going to be more of this. I'd rather have this than the... What do you do when the air says figure margins to large calls? I think it really depends, but you could solve it the same way that you solved it earlier today. So for example, if you have something that you want... Where is the question? Yeah, so in this case, you'll see that I use like the part MFRO that we use to make faceted plots. You can use the very same thing in the markdown file that you have been using to set the margins. I'll switch. Actually, that's exactly what I have. The part MFRO, the one and five. I'm going to also just try to change the size because the labels were getting cut off, but... You might also instead want to play around with the figure width and the figure height. And then... I'm playing around with all sorts of numbers. Okay, do you want to paste the screenshot of your code maybe? We can play around with it. So Emma, if you take a look, your figure width and figure height are quite small. So those are actually in inches. So they map to the height and width that you would have on either a screen or a sheet of paper. So you'd want the width to be closer, I think, to the 10 for a bigger pot like this. Yeah, so that's what it was originally. I guess I'll just keep playing around with it till it's happy. What's a lot of what this workflow looks like, actually, unfortunately? Yeah, but can we get your help on a question Christina is asking, right above Emma's. So she, I think it's stalled a tiny tech and it's still giving that error around looking for me tech. I think I've ever seen this error, but we can Google it and see what we get. Sorry, in the meantime, Christina, could you run the install tiny tech? Yeah, so you shouldn't actually have to run the library tiny tech in your code chunk. That kind of happens in silence as you knit. So I would actually remove that just to see if that stops the error. I'm sure that's not the only thing, but just... I tried with and without, but I'll try it without again. Yeah, you really shouldn't have to use it. Would you just try to run just the install packages command for tiny tech, just in case maybe it installed with errors yesterday and then it maybe didn't. I'm going to give you an error message or maybe you missed it. Sometimes that happens, but in the meantime, I will also take a look at this. Lauren, did you ever get an error like this running markdown? No? No, I've not seen this one. Yeah, exactly. Yeah, I was thinking the same thing, but it like did the whole thing again, installed it again the way it did before. And it's still, but it still says successful. I can put a screenshot of that. Oh, Diego. So you have a space at the top between output and HTML document. If you could just remove that and try to knit again. I think that might be the issue. Okay, Christina, sometimes you have to run these additionally, can you try to run that and see if that fixes the issue? Sorry, run what? So I just pasted it in the thread, but I sometimes like updates or installs itself in the background, so maybe she forced it to do that. So I just noticed that you have a space in the name of the chunk online 78. I was wondering if that was giving you trouble when you're knitting the document. It didn't, but I removed it anyways. I actually have a weird glitch right now. I was just trying to, like I'm just putting everything we did into that. Markdown, and I was putting the like loop to T test in. And I think it's like looping the table forever. I don't know. You think you have like an infinite loop there? Well, 17 pages. That's not infinite, but just proceeding. Yeah, maybe too many pages I think for how many T tests we're actually running. Yeah, 25, but I think, I don't know what's happening. It doesn't matter, I'll say. Okay, so Lauren, what timing works for you in terms of what you wanted to do for the next bit? I was thinking we would go until about... Yeah. Yeah, 4.30, and then I would go over the solutions for... Yeah, yeah, and that's all we have. And then, yeah, and then you just review what is there and that's it. So I'm going to give us maybe five extra minutes. And in the meantime, I'm just gonna actually post the solution right away so that when they go through them, whoever's interested can follow along with me on the file. I'm not sure if you mentioned it, but in terms of the numbering, I might have missed it, but can you remove the numbers? The section number? Yeah. Yeah, so at the top, all you'd want to do is just delete this... Oh, got it, okay. Thanks. Or is that it to false if you don't want to go about releasing rows and such? Okay, I think I'm going to go through the solutions now and I believe that Hashad has actually posted them on the course website. So if you go there, they'll be at the very bottom and you can follow along or you can play with it later this week or perhaps later today, depending on how keen you're feeling after this. Hold up, I'm just done. I think we're just waiting for a second. Okay, so this is what the full solution will look like and we've kind of looked at the finished product a few times now, but I'll go through it again in a minute. What I've done here is I've also pasted the code that we used to make all the different types of headers, just as a reference. And here we have the numbered list items and the unnumbered list items are unordered. You can make lists with all kinds of different symbols. So there's the plus signs and the dashes. Later on, I also show you that you can use an asterisk. They all render more or less the same way. On some machines, they will change the actual marker and you can just play around and see which one suits you best. On the right, you'll see a skeleton of your document. So you'll be able to navigate to different parts of your code where you've created headers and the indentations are just like the level of the header. So these are subheadings and then they'll indent even further with each additional subheading level that you've added. And so over here, we have the list that we've implemented earlier. So this is a single tick to show just syntax highlighting. Here, we have the inline code. Gabby, can I ask a quick question at this point? Right here, Diego had an error that said, and like right where you're at this quick stats. It says that object type closure is not subsetable. I feel like that usually happens when the object that you're trying to access doesn't exist. Yeah, right. And so it ran fine in the chunk above and then it doesn't run in the quick stats for some reason, like when in these tick mark sections. Right. If you don't know off the top of your head, we can look at it after. I'm just wondering if... Yeah, Diego, did you try to knit the file when it gave you that error or did you try to run like a single? Yeah, so when I try to knit it to either PDF or the HTML, like all of my data chunks run fine but it always comes to an issue when it comes to that. Interesting. And is it just on the screenshot on the slide? Yeah, it's the screenshot bit. It's line 35, you said. So that first line of the quick stats. Could something have happened to DF dollar age? Like, does that column still exist in the data frame? Yeah, if you go up here and then you just click, oh yeah, you can do that. So if you click this button here, does age have a bunch of integers in it? Yeah, yeah, so age is still there. Like it's still a column in the DF data frame. And if you run like just this portion in your console like that, does it return a number for you? So if I run the, like just the code? Just the mean and then brackets DF dollar sign age in the console. Yeah, and I still... It says error unexpected symbol in our mean. Sorry, you wouldn't want to, you would just want, in the console, you would just want to type mean. So you don't need the R here. Are you just... Oh, yeah, okay, then it gives the mean, yeah. Maybe we'll deal with it after this then. Yeah, it seems like a deal. Yeah, no, I don't know how to hold anything up. No, no, sorry, I just wanted to ask while she's on it, just in case it was like, oh yeah, this happens when blah, blah, blah, yeah. Yeah, thanks. Nothing at the top of my head, unfortunately. Okay, so the next bit we have is just the factoring. So again, I set a code to false because we wouldn't necessarily want the output, the success of those functions visible in our report. And then maybe what I'll do is I'll open up the report so we can look at it, I've activated it. I wanna do that and I'll just open it up. This is a quick stats and what that will look like. So over here, we have just this text highlighting that we asked for. And here we have the inline code. So this is what the mean of the age column is. This is its standard deviation and then this is the range. And the square brackets here, I just added myself. They're just for the context. Nothing fancy in terms of r is going in here. As you can see, like there's no mention of the factoring that we've done. That's because we set by code to false. So then here we have the aggregate functions we've used. So we're also not including them in our report. So then the next thing is actually visible are our tables. And so this is the rendering of three different tables. So the first one here is the treatment factor versus sex factor, male and female. And here are the treatment versus site. And the last is the sex versus site. And you see that here, they automatically set the row labels and the column labels for you. They'll center it and they'll add this caption. And that's all part of these three lines of code. So the caption is just another argument to our cable call over here. And the thing to note with a lot of these knitR functions that you use is that they'll generally only render when you actually press knit. So when you have to use one of these functions, you can't really press like this play button to run the code independently because it'll give you all kinds of errors that are generally fairly hard to resolve otherwise. And don't have a resolution in this implement because it depends on a lot of other factors. In the background. Okay, so the next bit that we have is this sumheading that I've included. So four levels of the high square test that we want to run. And each sumheading becomes like progressively smaller. So then it takes up a space and then it also allows you to kind of create a flow within your readings. And then just to jump back, because we set our table of contents to only two levels, all you'll see in the table of contents are the point ones or point twos and not the ones that are further down. So we can actually set the table of contents here to a depth of what they five and knit it again. So this is what the HTML will look like. You'll see in the case of, I'm just going to see if I can get you out. Oh, I thought you didn't. Okay, I will take a look at it later. What should happen is you should see additional levels to your students within these here. And they also come automatically linked to the appropriate spot in your actual PDF file. So where would it be? So next we have our bar plots. And like I said, I split them up into two different potions just that the space is a little bit easier to manage and they all fit nicely on one page. And that's what they look like over here. So just the same box plots that we looked at earlier with a nice little heading up here. And then the legend formatting that we've done, what's it best? So I set it up as a two-column row, which is this portion right over here. So instead of it being in a single column, which is what the default would look like, it's just in a single row. So it takes up less vertical space on your page. And that's like a nice way to do a parameter bunch of figures on a single page. If you have a type page limit on a publication, then you have your Y limits here or just expand it a little bit to 45 rather than what used to be 40, just to allow your legend to fit into the figure. And then the figure width is set to 10 and the height is set to three, just so that it doesn't take up too much space. And we can fit in this big figure in section three for the rest of the page. And that's just numbers that I played around until they look nice. This is a section of code that I wanted to include. Again, as Francis said yesterday, a really good case, I guess, or using our markdown is to show code that is needed to make an analysis, but then not necessarily show all the output from that code because it might be quite lengthy or not particularly meaningful. And so to demonstrate that, we have the melt function. I used the tidier version, which is pivot longer just so you have the ability to see what they look like. So this is the exact same thing as what Lauren had done with melt, which kind of breaks the different marker columns into a single column that has the marker identifier that we used to create our ggplot at the bottom here. So I silenced the output from that just by setting echo to false. Otherwise the code is exactly the same. And then I added a caption to our figure and that's just this section over here. So fig.cap and then we write paste so that it renders nicely as a string in knit and that's just another heuristic I have to follow with a string over here for what you'd want your caption to be. And you can use any of the paste function. So for example, if you wanted to be a bit more clever about it, you can maybe use paste zero and then use a variable name from rowing that on but that's a bit more involved. Yeah, and then as you can see here, you can set the same themes as you've set before. So this is something that, so if you look here, the labels are on an angle. So you can fit them nicely. I accidentally highlighted it. Mm-hmm. I'll just simply leave these for you. All of these guys point all six. Technical difficulties right now. My laptop is really not happy about running Zoom eight hours a day. Okay, so we're back at our box plot. We can see that our labels are on an angle and that's something that we can control just with the same ggplot commands that we learned yesterday. So you can set the theme. You can also adjust the background and the font and the text sizes the same way that we done before. And then knit will just render it within a table. So the actual extent to which you can control your code is the same as you've had before. All you'd really want to watch out for is like the spacing that you give the figure. That's one thing that's very finicky. I found with Armoredown. And then the last thing that I wanted to include is just the straight output of the t-test. So I find these kind of like already out of the box nicely formatted. So you can just pop them down into a report so that you can kind of show people what they look like. Again, you can play around with the width and height of these sections so that they don't cut off on the side over here. Then also if you have an HTML page that kind of already does it automatically. So if we open this in a web browser, for example, it'll look like this. Yeah, so as you can see, it's cut off a bit here. What's something you kind of have to watch out for when you do just a raw output. I'll just continue on the slide over here. But you can always play around with the width of that particular chunk to accommodate a little bit. Or alternatively, you can also access those sections with just inline code, the way that we did it with the mean and the standard deviation portions of this. And that's what this will look like. So as you can see, we did it for false so that you don't have to look at the code itself. You can just look at the output from the key test. And that's all.