Tour of RStudio

Now that you have successfully downloaded and installed R and RStudio, it is a good time to have a tour of the RStudio environment and see what functionality is available there. I should state that this tour will mix screen shot images form Mac and Windows sessions. There are few differences between the Mac and the Windows interface for RStudio. This is one of the advantages of RStudio; it operates in a similar manner across multiple computing platforms. Once you learn R and RStudio, you can use it anywhere.

When you open RStudio for the first time, it will look like this:



The RStudio environment has several function panels. Each panel will help you do things in your R session.

The command console

The command console is where R executes commands and usually responds to those commands. The one exception is when R draws a plot. The command console is in the lower left of the environment.  Here is the command console [shown highlighted] in the opening environment:



If the script editor panel is open, then the command console will move down and it will look like this:



You can resize the command console if it is too small for your workspace. You can vertically resize the panel by hovering your cursor over the = symbol in the boundary above the command console. Your cursor arrow will change to a quad arrow symbol. Once that occurs, click and hold then drag the boundary up or down to the size you want. You can also resize the panel horizontally by dragging the vertical boundary to the right or left. 

You can enter R commands at the command console prompt > and R will execute them when you press ENTER. Try this now by entering 2 + 4 then press ENTER. R adds 2 and 4 and returns the answer 6. You can conduct an entire R session by entering your commands at the command console prompt. Unfortunately, when we enter commands at the command console prompt, we may be unsure what we wish to do or we may want to repeat a command stream from a previous session before starting work on this session. That is where the script editor can help us.

The script editor panel

The script editor is in the upper left of the RStudio environment. If you are starting a new R session, or have closed the last open R script, the script editor is not visible. You can open the script editor by either creating a new empty script or by opening an existing script. You can open a new empty script by clicking the New File icon in the upper left of the main RStudio toolbar. This icon looks like a white square with a white plus sign in a green circle. Clicking the icon opens the New File Menu. Click the R Script menu option and the script editor will open with an empty script.



Your RStudio session should now look like this:



Your new script has a tab with the name Untitled1. Once you save the script, the tab will show the script name. Normally, an R script will have an .R extension, like MyScript.R. You will usually save your R scripts in your default folder. Another topic in this learning infrastructure will guide you through the steps of setting your default folder in RStudio.

The script editor has it's own toolbar. The tool buttons, from left to right, are: left arrow, right arrow [these are used to navigate through multiple open R script files], show in new window [this opens the current script in a stand-alone window], save the current script, source on save checkbox [we will skip this for now], find and replace [this allows us to quickly find specific text and replace it with new text], code tools [we will skip this for now], compile notebook [we will skip this for now], Run [this will run the current code line -where the cursor is placed, or it will run a highlighted set of code lines], re-run [we will skip this for now], source [we will skip this for now], and show document outline [we will skip this for now].

We will explore the editor panel in more detail later in this learning infrastructure when we learn how to create, edit, save, and use R scripts.

The environment panel

The environment panel is in the upper right of the RStudio interface.



The environment panel displays the current active R objects. In R an object is a container. You can think of an R object as being similar to how other programming languages use variables as containers. You do not have to remember all of your active objects during your R session. They will be displayed in the environment panel along with some of the details of their contents. The image above shows four objects in the Environment Panel: ir, x, y, and z. Try this experiment: type a = 45 in the command console and press ENTER. Your environment panel now shows an object named a with contents 45. 

The environment panel has it's own toolbar. The tool buttons, from left to right, are: open [can open a previously saved environment - good for restarting a past session], save [save the current environment to the default folder], import dataset [we will skip this for now], clear objects from workspace [clears all of the current objects], list/grid [modifies the appearance of the environment panel, and refresh [refreshes the environment panel]. 

The history panel

The history panel is also in the upper right of the RStudio interface. Click the history tab to show the history panel.



The history panel shows every line of code executed in the current session. The last line of code is at the bottom of the history list. You can copy any line in the history panel to the command console for re-execution by simply double clicking it. 

The history panel has it's own toolbar. The tool buttons, from left to right, are: open [can open a previously saved history stream - good for restarting a past session], save [save the current history stream to the default folder], to console [copies the current history line to the command console for re-execution], to source [copies the current history line to the script editor], remove the selected history entry, clear all history entries, and search history [searches the history stream for specific text].

The files panel

The files panel is also in the lower right of the RStudio interface. The files panel shares this location with four other function panels. Click the files tab to show the files panel.



The files panel shows the contents of the current working folder. This will be your default folder when RStudio opens. The directory path for this folder is displayed immediately above the list of files in the panel. The file names in the files panel are a helpful aid when trying to remember the name of a data file you wish to load into your current session. 

The files panel has it's own toolbar. The tool buttons, from left to right, are: new folder, delete, rename, more, and refresh.

The plots panel

The plots panel is also in the lower right of the RStudio interface. The plots panel shares this location with four other function panels. Click the plots tab to show the plots panel.



R will display the plots you execute in your current session in the plots panel. The example image above shows a scatter plot of two variables [Height and Body Weight] from a dataset [Cats].

The plots panel has it's own toolbar. The tool buttons, from left to right, are:  left arrow, right arrow [these are used to navigate through multiple plot images], zoom [we will skip this for now], export [this allows you to save your plot as an image file, a pdf file, copy it to the clipboard for insertion into another file], remove the current plot, clear all plots, publish [we will skip this for now], and refresh the panel.

The packages panel

The packages panel is also in the lower right of the RStudio interface. The packages panel shares this location with four other function panels. Click the packages tab to show the packages panel.



The packages panel shows all of the R packages installed on your computer. The packages that are active in your current session show a check in their check boxes. 

The packages panel has it's own toolbar. The tool buttons, from left to right, are:  install [you can use this to install new R packages from CRAN], update [you can use this to update the packages on your computer], search [you can search for a package installed on your computer], and refresh the panel. 

The help panel

The help panel is also in the lower right of the RStudio interface. The help panel shares this location with four other function panels. Click the help tab to show the help panel.



The image above displays the documentation for the Iris dataset that is included in the datasets package that comes with the base R installation.

The help panel has it's own toolbar. This toolbar contains two tool buttons. They are: home [this will return you to the help home page and clear you help search history] and search help. 

We will explore additional help resources on the internet in a later learning infrastructure topic.





Return to the R Learning Infrastructure Home Web Page