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.  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 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 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.  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.  I just did command enter just like randomly. Right, so that's kind of an important thing to mention.  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.  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.  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.  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, 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.  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.  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 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...  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 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.  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.


Hello in this lecture, we're gonna continue on with the master budget that we started the master budget last time So if you haven't seen the first part of this You may want to look at that first and then move on to the second piece of it The second piece here is including direct labor factory overselling general and administrative parts of the master budget We will be able to first a word from our sponsor Well, actually these are just items that we picked from the YouTube shopping affiliate program But that's actually good for you because these aren't things that we're just given to us from some large corporation Which we don't even use in exchange for us selling them to you These are things that we actually researched purchase and use ourselves Acer 27 inch monitor. I've been using an Acer monitor as my primary monitor for a few years now This is the first Acer monitor that I have used after having used a series of different brands of monitors in the past The Acer monitor has been performing well, and I'm trusting the Acer brand more and more as I use the monitor I have a 27 inch monitor, which I think is ideal for what I do which is of course the screen recording and the editing if you would like a commercial free Experience consider subscribing to our website at accounting instruction calm or accounting instruction dot think of it Calm where we have many different courses You can purchase one at a time or have a subscription model given you access to all the courses courses which are well organized have other resources like Excel files and PDF files to download and no commercials List the components of the master budget create direct labor budget create factory overhead budget Create the selling expense budget and create the general and administrative budget Alright, so let's go through the process first We won't go in detail of here But we do want to keep in mind the fact that all these budgets are going to tie together and we're going to do it in This order in order to get to our master financial statements budgets of the income statement to balance you at the cash flow budget So we're gonna start off with the sales budget Then we need to do the production budget in order to get the units that we need to produce Then once we have that we can figure out how much the direct materials will need how much direct labor will need How much overhead will need we can also have the capital expenditure budget at this point as well as the selling and Administrative budget then we can have the total cash budget that we will need and then we can create the balance sheet and The budgeted income statement and the budgeted statement of cash flows This is the order we need to go through in order to Have everything flow in the proper format because many of these steps need to happen Prior to another thing happening. So here we go for now. Remember that last time we talked We already did the sales budget So we did that last time here's just a recap of what it looked like We use that sales budget in order to create the production budget how much units we're going to produce We needed to produce and then we use that for step three to have the raw materials budget That's where we left off last time now. We're moving forward this time. We'll move forward to the direct labor budget. So No, we're jumping back to part two here. I'm going to use the production budget to help with part four Which is the direct labor budget. That's the order that we're doing this end So we have the units that we're going to produce. These are how many units we're going to produce We're talking we're looking at like guitars of this how many guitars we need to produce We're they're gonna think about how much labor will we need in order to produce that then, okay? Well in July, we're gonna say the budgeted production We're gonna have the production is just being pulled down for this calculation. So there it is for July There it is for August coming straight down and there it is for September So that's how these two budgets are related the production budget How much we're gonna produce and the direct labor budget? How much hours are we gonna have to need and how much money we're gonna have to spend for the labor? We're gonna take that we're gonna take that multiply times the labor required per unit now We're gonna say it takes a half an hour half, you know point five hours We usually think about labor when we think about paying people hourly obviously But when we start to measure things it could get very precise You might see something broken out of course in terms of minutes How many minutes does it take to get something done and just be aware that you'll need a conversion if that happens? Because there's 60 minutes and the conversion can be a little bit tricky So you just got to make sure that when you're thinking about The units of time the conversion between minutes to hours here. We're just saying it takes Half an hour. I'm not putting 30 minutes We're putting half an hour and that of course lines up nicely to when we have to multiply times The hourly rate. That's what we're gonna need. So you also may be thinking well What if we pay someone salary in this type of thing? We're thinking about hourly wages in this case when we're thinking about producing the item if people get paid differently We might have to have some kind of estimate in order to do a calculation like this We're gonna need some estimates in the budget in order to figure this out This is the type of area where you can probably picture someone with a stopwatch trying to figure out how long it takes To do a particular process and trying to figure these things out and refine our estimate down But it will need to be some type of estimate. All right So then we're gonna say that the total hours needed then is going to be the in this case the 19586 times the point five half an hour is the 9,793 hours the 20,000 times point five is the 10 the 25 times the point five is the 10 to 50 that's how many hours we are projecting out We will then have the hourly rate which we're saying is $14 an hour Again, some people might make more some people might make less we could get into a very complicated projection on how many you know How much hours it would be in different pay levels? But we need some estimate and this would be the type of estimate that we would have them and then of course if we Multiply that out if we have the hours times The rates per hour then we can get the dollar amounts. We got the hours times the rate per hour We get the dollar amount the hours times the rate the dollar amount This would be the total that we're gonna extend in Dollars again make sure that if you see something that's in minutes Make sure that you make that conversion two hours in order to multiply then times What's probably gonna be the hourly rate is how it's game We don't usually think about the minute rate in terms of pay So be careful on that now. We're gonna take the direct labor budget and help us to Create the factory overhead budget or we're gonna create the factory overhead budget now when we think about factory overhead budget The thing that we need to keep in mind is the fact that usually there's two components to factory overhead We have some costs that are going to be variable and some that are fixed We may have some mixed costs even but we need to break out those two We need to figure out how are we gonna break these things out? How are we gonna deal with the variable portion the fixed portion very? I mean the fixed portion is usually pretty easy because that's just gonna be the same We can like take last year's numbers usually and just you know project them forward They're not gonna change they're fixed kind of like the rent variable will change in some way and this example to reflect this in this example we're gonna take the Direct labor hours which are being pulled down from the direct labor budget here direct labor hours direct labor budget We're gonna multiply that times the variable factory overhead rate So that's gonna be in this case 2.6 So that's gonna be the givens for this particular problem again in real life We'd have to be I mean in a book problem We'd have to be given this type of information to calculate the variable portion in some way in real life We would have to figure out some kind of estimate to accurately figure out what the best estimate would be for the variable portion This is what we're using here that gives us the budgeted variable overhead So the budgeted variable overhead the 9 7 9 3 times 2.6 gives us the 25 for 61 the 10,000 times 2.6 gives us the 26,000 and so on and then we come up with the fixed portion Fixed portions pretty straightforward. It's pretty easy. It's kind of like the rent You we just say well, we know what the rent is it's gonna be the same going forward. It's always the same So when we think about the fixed cost we can think about what we traditionally often think about when we think about a budget And that's just well, what was it last year? It's gonna be the same next year That's not the case for everything we've seen But that's that is the case for many pieces and the fixed portion piece is usually in that type of area So then the total then would be the variable portion plus the fixed portion For example the 25 461 plus 21 gives us the 46461 the 26,000 plus 21,000 gives us the 47,000 And so on and so forth until we have the total In terms of the overhead for dollars of the 141 111 All right, now we're gonna look at the selling expense budget We have the same kind of thing when they think about the selling when we think about production of Inventory someone that a company that produces inventory We usually think about the selling and administrative are often the period costs and they're often like overhead in that They have the fixed portion the fixed portion is gonna be easy because the fixed portion is fixed when we think about the selling costs We might think about salespeople salary or the or the cost of the Store that we sell in terms of rent or in terms of depreciation. Those things are usually fixed pretty straightforward We may have the variable portion. However, for example, we could have the budgeted sales Times the sales commission. So if we pay commission, that is something that's basically Variable in nature and we'll have to figure out. Well, okay. Well, that's gonna change. That's not gonna be something That's gonna be straightforward We're gonna need the sales number then if and if all sales are gonna be commissioned sales Then we can take total sales and multiply times the commission if only portion of the sales or commissioned sales We're going to figure out what that portion will be multiply times the commission and if we did that then we're gonna take the sales 494 400 times 9% is the 44 496 and so on and so forth for July, August and September Then we're gonna have the fixed portion. So we have the fixed salaried individuals There's this pretty straightforward We know that we you know, we're gonna take the yearly salary and divide it by 12 and we'll get the yearly So the fixed portion is easy if we add those two up We get the totals for example the 44 496 plus the 3500 gives us the 47996 the 42 336 plus the 3005 gives us the 45 836 and so on Then we have the general administrative area again, usually fairly straightforward We're talking about the office in this case and the office usually have salaried People work in there include in the accountants who usually get paid salary. So that's gonna be pretty much the same It's a fixed cost going forward the the rent on the office or the depreciation on the office Usually these are fixed things usually This is a pretty easier portion of the budget because it doesn't vary in terms of changes with production So in this case, we're just gonna say that the salaries is Salaries so they're fixed in this case 11,000 per month. We just take the total salary divided by 12 That's what people are gonna get paid. We do have to watch out Of course for increases and fluctuations in salaries, but pretty straightforward then we have the interest We're gonna include interest in this case in this case We have a loan out and we are currently paying apparently 5,000 of interest This is interest rates are usually pretty fixed as well. So as long as if the if the interest I mean if the loan amount doesn't vary like if we're paying we're not paying off principle Then the interest should be fairly constant on that as well for paying off principle Then we just look at the amortization table and figure out what it's gonna be month to month And that's all we're gonna have in terms of the general admit and administrative So that's what we're at at this point and we will move on forward it to cash In calculating cash and then the cash budget next time


Okay, because, you know, even when you think about treetop nowadays, I think about treetop parruses. So I'm not thinking about another gang before that call. That's what people say. Well, parruses and bloods are the same thing. I beg to differ. You on boss talk one on one, one on one. Here we go on talk.  That's a whole number. Yeah, but you got treetop. All of these things sanctioned and when you going, like, through the system of jail. Now, that's just like, you got, if you believe the fallacy, that's California, right? That a note gets put under your door. We don't want you that bad. If you can't put in work, you couldn't be a BGF.  Explain what a BGF feels to people. Yeah, that's what I would like for me. We being a Texas folks, okay? That's a California thing. It's all over the thing. I mean, really, it's a Black guerrilla family. Let's talk about that. It started with the Black Panther Party. Well, it did, it was the Black Hand first. That's what, before Doc Dem started, damn, what's his name? Well, I can't remember the brother's names. The OGs that really started the Black Hand. And it went in from the Black Hand and the Black Panther Party came up and George Fleta, not Rochelle, George Fleta, John Cluchet out of Compton, those are the Soledad brothers. And they formulated the BGF, the Black guerrilla family, the dragon. And they brought that in as a revolutionary concept on a prison element aside from the Black Panther Party was a political movement on the street. So the BGF sole concept was to search and destroy. And that's to dominate the prisons. In 1969, George, John Cluchet out of Compton and Fleta Drumgo, they allegedly killed the police in Soledad. In 1970, or 1969, 1970, George's brother, Jonathan, tried to break him out of jail. He didn't come to court though.  Everybody got killed in the van, a judge, a district attorney and some. So Jonathan was 17 years old and went and took over the courtroom, right? And 1971, O.C. Allen, Jesse Phillips, Roosevelt, Jimmy James, they killed the police in Owing and Soledad. They were the Soledad seven out of Compton. Wow. So they came to San Quentin, 1971, George Jackson got killed in the San Quentin yard. The police killed him in 1971. So that was the building of the BGF, the Black Gorilla family. That's before Crips, that's before Bluzz, that's before Pyrrhus, they were, and before them, like I said, Captain Shahi was a businessman. After the businessman, it was the Slossons, the Gladiators, those, we've had gangs ever since. So it was gangs before Crips and Blood, it was gangs before that? Yes, you what? You thought they just popped up? When you say businessman, was it UBN? No, businessman was, UBN is a part of a set that they brought up, it didn't, UBN didn't start until 86, 87. You know, you had, before that it was called, they had for the Bloods and Tracy was called Bloodline, you know, but those are gang elements.  Then the Crips, they had C-notes, C-notes, what was they other? Well, you got to talk to Melvin about that. Because all you keep hearing is Bloods and Crips, so it's like, and all these other gangs like derived from that, so like it just baffles me like, I just didn't know that there was actually other gangs before Bloods and Crips. Oh yeah, oh yeah. Like I say, when I originally grew up, I originally grew up, my neighborhood was called Treetops. Treetops, yeah. Because all our streets, I'm from Elm Street, we were in Freddie Cougar out in there. So all the streets were named after trees. Fruittown is cherry, fig, plum, so they became Fruittown. The swamps in Compton, because it was a swamp over in their neighborhood, so they was the swamp area. Then they had Spooktown, because the train tracks came through 12 o'clock at night and they were woo, and they thought it was Spooks. Then they had, what Nutty Block was, they were called Boot Hill because they got the two graveyards in their neighborhood. And those are all names of gangs before Bloods and Crips? That was before, even from the 60s. Okay, because you know, even when you think about Treetop nowadays, I think about Treetop Parous. Parous, right. So I'm not thinking about another gang before that calls. Yeah, that's what people say, well, Parous and Bloods are the same thing. I beg to differ. It's a good thing you said that, because when I was, I don't know how much Google is correct, but when I was doing some research on it, when, I think, who was it? Owens and, what was the other guy? It was Owens and Scott, who, they say that started the parous, right, right. So, because it was a fight or whatever that caused, but the thing is that if those two guys were together, why didn't they start the Bloods together instead of creating one created Bloods and one created Parous? No, that's not the, Vincent and Sylvester Scott. Right. Vincent and Sylvester, they're both, Parous is a street in Compton. It's not a gang, it's a street. And all the, every family had five or six boys on their street. So they were the Parous boys. And so once that situation happened and they started calling them Roosters because it was red. And they would say, we the Parous boys. So once they became Roosters and the Bloods out of LA was in red too, so they associated. You know what I'm saying? You got different brands. It's the military, but you got the Navy, you got the Army. They're not the same, aren't they? But they are military. The Air Force don't do what the Army does. The Navy don't do what the Marines do. Parous with 10 square miles. It ain't but two sets in Compton. Parous and Crips. We don't have no Bloods in Compton, California. It's not a Bloods set in California. But it's a Bloods set, Circle Cities in Watts. You got 30 Parous in East LA. You got Avenue Parous in Inglewood. You got Neighborhood Parous. You got Parous in Pacoima. You got Parous in Pomona. You got Parous in Sacramento. We got Parous all over the world. So it wasn't Benson Owens who started that gang. Lil Vence grew up on Parous and Putin grew up on Parous. So he didn't actually start it though, that gang. They were the original seven dudes that put the name out. Oh, okay, okay. I was just trying to figure it out because when I'm doing recent reading, I'm like, those are the only two names that they mentioned. And I'm like, okay, so if they were friends, like why did they just create one big one instead of- They got one big one. Because when you talk about Fruit Town, when you talk about Cedar Block, when you talk about Campanella, it wasn't like it is today. It was just, because you can hear a lot of Crips talking about their activities. But you very seldom, and I've never heard, you cannot tell a LA Crip they came in and did a drive-by in Compton. Because our streets are so confusing. If you're not from there, you can't just come up in there and get, because everything down Rosecrane is all Parous. From the Harbor Freeway down to the 710 and in the middle of that is Santana Block, Crips. But everything from one freeway to the other freeway on Rosecrane is all Parous. From 135 to cross Atlantic, everything in between. So if you don't know where you're going, you can't go east or north or south, east or west and not get your hat brought to you. So it ain't many dudes that's gonna come across El Sagana or 120th to do anything in Compton because it's not their terrain. But we'll go to their neighborhoods, bus and come right on home. I don't do that type of stuff. I got big business with White America.  Yeah, we on boss talk one on one, one on one. Yeah, we gonna talk.