Rstudio Tutorial

These are my notes on Rstudio tutorial.

Samsung Store on Amazon! If you buy something, I get a small commission and that makes it easier to keep on writing. Thank you in advance if you buy something.

Rstudio is a free package that allows you to run statistical packages. It is an open source IDE which runs R commands and scripts. Rstudio adds a lot of functionality, it is very useful for beginners.

 

Opening View

When you first open Rstudio you should see 4 rectangles, that is your interface. Each panel does something different. 

 

The top left panel is the source and where you will save and run scripts. You can save from this panel and easily access scripts without having to leave Rstudio. The bottom left is the R console and you can see the output of your scripts or commands here. 

 

The panel on the upper right is the environment panel. It shows you the variables that are available and what is in your working memory. The panel on the lower right has various functions including help, plots, and accessing your files.

 

Configuring the Interface

You can configure the look of Rstudio by clicking on “workspace panes” under the main menu. Click on “pane layout” to dictate what you want to see. Under each of the 4 sections you can select the different tabs that will appear. This will depend on your needs. If you do not know what you want right now, just leave it on the default. It will always be there if you want to play with it later. You can also drag the 4 interfaces around so you can get the size and appearance you want. 

 

Importing Data

One of the first and easiest ways to open a dataset is to look in the top right interface, click the “environment” tab, then select “import dataset”. You will see that you can open up text files, Excel sheets, and other types of data sets. a

 

First Tasks

If you create a vector, you will see several nice things that Rstudio does for you.

x=1:50

y=51:100

plot(x,y)

Under the “environment” tab at top right, you will see your variables that are in memory. This is great because sometimes we are doing many things at once and want to know we have the right variables. 

In the bottom right, we see the plot we just made. We do not have to have a separate window or go anywhere else for it. We can save the plot by clicking the “export” tab and selecting the option we want.

 

Script Panel

The script panel is in the upper left. It lets you load and save scripts in one place.

Rstudio can help in the creation and management of R scripts. To do this, go to 

  • File
  • New File
  • R Script

Enter in some commands that do something and go to File and hit save. 

We can also create a Project. This allows you to to manage all your files and scripts related to this project in one place. 

 

Console Panel

The console is the bottom left panel. This lets you interactively enter commands and work with variables. 

 

Environment Panel

It will automatically show the variables you created last. The panel also shows what their current values are. You can click the “broom” icon to clear the environment. 

 

File and Plot Panel

This is on your bottom right. It has several tabs by default. It will show you a file tree, the plots you make on the console, and a help section to give you hints.