 All right. Hey everyone. So this video we're going to talk about the basics of our markdown. They're so simple that it shouldn't be too difficult, but I want to talk about how you get the system actually set up. So I will say I use Vim to compile our markdown. Most people who use it use RStudio. I'll talk about both options. But first, let's talk about basic installation. So if you don't have R installed, you do need R. So to install that, you know, if you're a Linux user, you know how to do it, just whatever your package manager is and install R. If you use Windows or Mac, you'll probably have to look at r-project.org, I think is the website. But the packages you're going to want to install is R. And the other thing is Pandoc Site Proc. I think that's it. Yeah, Pandoc Site Proc. So Pandoc Site Proc is the thing that our markdown uses for like making citations, like references if you have a bibliography file. So since I'm going to be writing papers and stuff in our markdown, that's the kind of stuff I want to have. So I've already installed both of these packages, but these are the ones you're going to want if, you know, you're using our markdown. So the other stuff that you're going to want to install is R specific packages, specifically R markdown, because we've installed R. If you run that command, but you need to install R markdown as well. So to do that, you want to go into R. It's probably the easiest way. So I like going into R as root, just because it'll install packages for every user. And also if it installs the default location for like user installation, it's like just the folder name R in your home directory, which is really ugly. It's not important, but you know, anyway. So when you're in R, you can just run the command install packages, and you're going to want R markdown. Just run that. It's already installed on my machine, but that's all you're going to need to run our markdown. The only other issue is how you're going to actually write the documents and stuff like that. So I'll go ahead and show you the more common way of compiling our markdown. And that is using R Studio, which is an IDE that you can just look up and download. I usually do not have it installed, but I decided to install it just to show you how it works, just because this is usually how people do it. So when you actually start the program up, let me get rid of this. So when you start the program up, it's going to look like this. You can start an R markdown file, just going to file, new file, oops, and R markdown. And just do whatever here. So you can basically write your document here. I'll go ahead and introduce you. Now I'll do the actual writing in the terminal, because that's the way I do it. But you can knit it here. That prepares it for, actually compiles it. So you can knit it to HTML or PDF. But this is how you do it's pretty simple in R Studio. I just don't like having a really big program. I find it easier to just do it in the terminal window. So I'll show you how to do that. So I use VIM. And in order to compile our markdown in the terminal, I have made a little VIM shortcut so that whenever I'm in an R markdown file, I can automatically compile it to PDF or HTML or whatever. And I'll put a link to this in the description. But the line that I put in my file is right here. So this maps F5 to the following command. It just literally runs a bash command. It echoes some stuff into R that tells it to actually render the file that we're in. That's all this is. So if you just copy this and put it in your VMRC, whenever you type F5 when you're in an R markdown file, it will compile it. So let's go ahead and actually get into how to actually write this language, which shouldn't take very long because it's a markdown language. It's super simple. So let's say rmarkdown.rmd. rmd is the typical ending for rmarkdown files. So you can have a, what's the word, a preface? What's the word? It starts with a P, prolog, whatever, the thing that's between hyphens, right? So you can have metadata up here. So I can say stuff like title. My first rmark, markdown document, author, Luke. And one thing that you're probably going to want to set is output. So I want this to output to a PDF document. So I just say PDF underscore document. Now I should say none of this is actually necessary. You don't need to do any of this. It's just I want this specifically as a PDF and I'll put title and author just for sake of example. But to actually compile a file, it's not like LaTeX where you have to have some code in there by default, just so LaTeX knows what to do. You don't need any of this in rmarkdown. So anyway, to actually write rmarkdown, it's pretty intuitive. You just type. And that's how you make your typical paragraph graphs and stuff like that. To make a line break, you need two returns. So these two sequences are going to be two different paragraphs, but this is not going to be a different sequence. So bullet point lists are with star. So you can make a list of different things. Or you can make a numbered list with numbers and stuff like that. But so section headings are with pound signs, hash tags, whatever you call it. So this is section heading. Or we can make a subsection, subsection with two of them or a sub subsection. So sub subsection. So you have italics. And to make italics, you just put whatever you want in in between two asterisks in between two stars. I always there's so many times in my videos, I messed up that word, but who cares? It should be renamed. So italics, you can have bold between two stars stuff like that. So I'm going to just go ahead and f5 and compile this. So I might have said it before, but by default, our markdown will compile to an HTML. But since we've specified a PDF document, it's going to be compiling to a PDF. So I'm going to go ahead and open this document here. So we have our section heading, all of it's nicely formatted. It's very reminiscent of the output of LaTeX or something like that. Now, speaking of LaTeX, you can put arbitrary bits of LaTeX code wherever you want in this document. So I can put a table of contents. So some LaTeX commands will not work on every kind of document. So I think if you compile this into an HTML file, a table of contents won't work, but it does work fine for PDFs. That's when you really need it. So you can do stuff like that. You can put pretty much arbitrary ticks, things, you can put pretty much anything you can do in LaTeX, you can do in our markdown. So one of the main reasons I started using our markdown is to be able to have code snippets and have them run automatically. So you just have three grave accents. What are those things called? I don't know. If you have three of those in between them, you can put snippets of code. So right here, I've designated this code as being R. So I can write just anything in R. So let's say I have like 56 raised to the 19th. Actually, let's put that in quotation marks and we'll multiply that by five or something like that. So that's valid R code. If I recompile that, it's not just going to compile what I wrote, it's actually going to run the commands in R. And it outputs a nice little answer here. So this is how you do it for specifically R code. You can also use other stuff. So let's say you have some Python code that you want to throw in here or something. So I can just say Python and we'll say something like what are we going to say? So x or z equals, you know, is a list with some numbers in it for y and z print y times five, something really simple. So if you want to run Python, let's see if that actually works. I think you need an extra package for it. I think, yeah, I have an installed. So the package you want, if you want to install run Python code, for example, you have to install it in R itself. All you have to do is, excuse me, install, actually I wrote it down, reticulate, install package is reticulate and just install that. I already got it, but that's just so you know. So R Markdown again has sort of the perks of LaTeX. You also have this code that you can run inside of it. Now the other thing, again, as I mentioned before, I can output this just as well to HTML. So if I just delete this by default R renders to HTML. So I can now actually open my file here. And you will see that I have a very nice formatted when it comes up. There it is. Okay. So here is a R Markdown document. Actually the default CSS is pretty decent. This is a very readable website. So you can just as easily have HTML files or PDF files or whatever you want. So the last thing, so we talked about the LaTeX code, we talked about actually running things, how you do it, we talked about the packages to install. The last thing I think is pretty important is actually citations. So if you're actually going to end up writing much of stuff in R Markdown, it's nice to be able to actually cite stuff you need for whatever. So I'm assuming if you're familiar with LaTeX, you know how to make a bibliography file. I have videos on it. You can check them out, but you can look them up yourself. But if you want to put in citations, actually let me go back to having a PDF. If you want to have citations, you first off have to tell it what bibliography file to use. So I'm going to say bibliography file, which is in Home, Luke, Documents, LaTeX, Unibib. So in order to actually cite things, this syntax is actually super simple. So I can say, I can do, let's see, Chomsky 2000. Just run that by, and Chomsky 2000, of course, is whatever you happen to label your stuff as. And if you have Pandoc site proc in there, you'll notice that it does successfully compile. So here, it actually lists out whatever the citation is, and it will actually put the information here at the bottom. Actually, it'd be nice if we had a little thing down here that says, like, references or something, references. I'm doing it as if this is a serious document. So you can also do this in different ways. So if you want a parenthetical citation, you can put it in the brackets or whatever. You can also do something, let's say you refer to the author in text. So I say something like, you know, my boy gnome, I can still say, if I put a negative sign in front of this, it's actually what it actually is going to do is actually put it in brackets, because that would make sense. It's going to omit the author's name. So that's if you refer to the author in text, or if it's obvious in the context or something like that. Give it a second. Okay, there we go. So now we have, yep, so we have normal citation, parenthetical citation and citation without the author name. And of course, we have it all down here. So anyway, that's really the basics. I did a bunch of videos on LaTeX, but if you know LaTeX, this is pretty much all you need to get into our markdown. I said in the last video, I think I'm going to start using our markdown as a main, a daily driver, as they call it. I don't know why they call it that. I think it's for people who have multiple cars or something. I don't know. I don't know. A lot of Linux people say daily driver, but whatever. So anyway, that's all the basics of our markdown. Just throwing it out there. I'm going to be doing a series on our stick around for it. And I'll be putting up more videos on different stuff anyway. So do you guys next time.