Join Mark Niemann-Ross for an in-depth discussion in this video Using RStudio, part of Code Clinic: R.
- Throughout this course I'll be using R Studio. Since this may be an unfamiliar tool, let's spend a brief amount of time learning how to navigate through the different areas. R studio is both the name of an IDE, and the organization that created and supports it. R Studio also provides packages such as ggvis and dplyr. Later in this course, I'll show the use of Shiny, a tool to build web pages.
So let's take a look at R studio, an integrated development environment, or IDE, R Studio has four main windows. Windows can be expanded or reduced, and panes can be re-sized by dragging either vertically... or in the horizontal bars. In the upper left, is the source code window. Code can be written, you can run a line of code with a control or command return, and there are several quick tools.
I'll demonstrate these in action later on. In the bottom of the code window, you'll see a small pop-up that will show you function names and other significant parts of the code. There is another pop-up that indicates what type of text file or code file we're looking at. Note how the top line changes depending on what type of file we're working on. In the lower left is the console window.
You can type commands directly at the greater than prompt. Such as, Print "Hello" This is where R prints errors and returns values. Clicking on the top line displays the contents of the current working directory. Notice that the current working directory shows up over here in the Files tab. The upper-right panel shows two tabs, Environment, and History.
The Environment tab lists data sets, values and function. It updates in real-time, so for example, if I use the console to create a new variable. Say, myVar gets 1, you'll notice that the environment shows I now have a new value called myVar and its value is 1. History will list commands as they're typed in. I can always go back and retrieve a command that I typed in previously.
Using the commands in the top line, I can save these history files, I can reload a history file, I can select a line and send it to the console, just simply by clicking on To Console. I could also send it to the source file up in the upper-left hand corner. Or I could delete, or clean everything. Finally, in the lower-right corner is a tab for Files, Plots, Packages, Help and Viewer.
The Files tab can be used to navigate through the documents, so for example, if I'm looking for exercise files, I can just simply click into that folder. Here's where I will find all those exercise files. To load a file, I can simply double-click on a name. And it will load into the code window in the upper-left hand corner. Plots will be used to show plots later on, and in particular when we do The Eight Queens, we'll be using this window heavily. Packages provide R with additional functionality, such as Statistical Analysis, Mapping, Database Integration, and Other.
Help shows information about those packages or functions. We'll be calling up this window a lot in future sessions. For example, I can find the Help file for CCF, just simply by typing ?ccf with a return. And that will pull up the help file for cross-correlation. If I'm looking for a concept, I can type in two question marks, ??html. This will search through all the documentation for any files that have anything to do with HTML.
The viewer window is a simple HTML viewer. There are also several menu commands not shown in the main menu. These include commenting, integration with the Shiny web server, and others. For more information about R Studio, go to R Studio, Help, R Studio Documentation.
Mark introduces challenges and then provides an overview of his solutions in R. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.