 Hi, I'm John Little, and you're watching the Introduction to R Learning series. This series is part of the RFUN Learning Resource website, which is sponsored by the Center for Data and Visualization Sciences, part of the Duke University Libraries. In this section, we're going to tour the RStudio environment. We're going to learn how to create a blank RStudio project. We're going to take a look at the quadrants on the screen, the console, the files, packages, and help, the environment quadrant, and the script editor. We're going to talk about R Markdown. We're going to switch back and forth from other RStudio projects. And we're going to look at the keyboard shortcuts. So let's get started. First, let's create a blank project. I'm going to start RStudio by finding the RStudio icon in my Finder and launch it. And there is a blank RStudio project. We see three different elements of the screen, aside from the menu bars. At the bottom are files. This is a different or alternative view of our file system. On Windows, if I open my File Explorer and I browse through my documents to one of my RStudio projects, all of these files are accessed by clicking on the .R, P, R, O, J, or R project file. But they're the same files that are presented right here, if I'm in that proper project. So if I switch projects, I'm now looking at the files in that RStudio project. So there's the Files tab. Packages tab is really handy in case you want to install new packages. For example, I can click on this Install button right here, or I can update my packages. And a really handy package for everybody to use and download is tidyverse. I'm not going to install that now because it takes a moment. There's also the Help screen. I needed information about the plot function. I could just type in the function name and get information about how to use the plot function. Up in the upper quadrant on the right-hand side, there's the Environment tab. So if I, for example, needed the cars data set to be in my Environment data tab, it's displayed right there. It tells me it's 50 observations and two variables. I also have a History tab that can be useful. And I have a Git tab because I've already configured this project to work with Git. You may not have that tab if you're on Windows. The other thing that we have here is the console. That's the principal way to interact with R. So I can type in a very basic mathematical equation and get a response. I could type in a more advanced mathematical equation and get a response. I can do all of my R work in the console, but it's hard to reproduce that because I'd have to remember all of the steps that I did. So the solution to that is to do your work in a script. There are lots of different ways to use scripts in R. I recommend that you use the R notebooks to develop your scripts. And then if you need to convert them to R Markdown documents. But R Markdown notebooks are notebooks. An example of literate coding, which is very reproducible. In other words, it's easy to keep a record of all of your work. Easy to explain your work not only to yourself, but to others. And then when you're done, you can render that into a report that you can share with non-coders with or without code. It's up to you. So here's an example of an R Markdown document. At the top, the first four lines is a very simple YAML header. I can add additional metadata. And I can also add a date. And if I put an R function in back ticks, I'm sys date. Oops, I need to proceed that with the letter R. Sys date. When I render this report, it will automatically pull the machine date and post that as the date that this was published. And then here's an output type. There are lots of different output types you can use. We'll talk about that in just a second. The other thing, aside from the very simple header, is there's pros separating code chunks, right? Now this document here actually explains everything you need to do. I recommend that you read through it. But if you need to learn more about R Markdown, there's a link right there. It tells me that if I hit shift and click, I can get more information about R Markdown. I can click on the get started guide. Or also very handy, I can open the book, the free book, which explains in great detail everything I can do with R Markdown, how I can use R Markdown. It's worth noting the book cover basically explains that you can render multiple different kinds of reports when you're done. So I can render web pages, websites, dashboards, Microsoft Word documents, Microsoft Excel documents, eBooks, slides, PDF documents, the list goes on. Okay, back to R Studio. R Markdown basically allows you to use code to explain your code analysis that's going to be inside the code chunks. So you can have multiple code chunks. Just putting in another code chunk says right there, I can pick a blank line and go up to insert and choose R because I'm programming in R. And here I can type cars. That's that onboard data set. Read through that. Now if I want to execute these code chunks, the first one will use the plot function on the cars onboard data set to get a visualization a scatterplot of the stopping distances of cars going at various speeds. These are from the 1930s. Maybe they're from the 1920s, and here are the stopping distances. I wanted to look at cars data set without plotting it. I can get a visualization of the cars and I can scroll through 10 rows at a time. And if there are more than two columns I can scroll to the right and left. For information about cars I can highlight that and on my Windows keyboard I can press F1 and it will bring that object name up in the help. So I can learn more about cars. It's cars from the 1920s. If I needed more information about the plot, could highlight that and hit F1 and get more information no matter how you use the plot function. When I'm done, I can preview the document. All I need to do to preview this document is save it. I'll call it demo2 and hit save. It'll get an RMD extension for R Markdown and then I can click preview. When I preview it I can see it in the viewer here or I can also, going from the files tab, look at demo2. I can take one of these words bold by using more R Markdown, some of the R Markdown code. Now if I look at this in my web viewer, in my web browser, there's a view where the word is bold. That link is hot so I can click on it. That's italicized. I wanted this code to not appear because maybe I'm having a non-technical audience. I can go over to this gear and choose show output only and apply. I can rerun the whole thing and preview it again. Go over here to my web document and you'll notice I have access, I have the ability to present or not present my code as needed. Check this out. Check out R Markdown. It's really useful to explain in prose in your natural language what your analysis is about. And then render the report for your audience. This way, in a reproducible way, if you go back to your project six months from now, you don't have to just read the code, you can read the explanation. You can read your explanation as you wrote it. If you need more information about R Markdown. I have a quick reference guide right there. And I already showed you that every R Markdown notebook that you create will have a link for more information about R Markdown. In summary, the four quadrants of the RStudio development environment include the console, the script editor, the environment pane, and the files pane. If I needed to switch to another project, I could simply go up here. And choose a different project. If I click on the word, it'll close my existing project. And open up the other project in this one. This one's called test one. If I needed to multitask and have two projects open at once, I can click on this icon and have two projects open. And then I can switch back and forth if I want to.