RStudio and Its Procee 7
RStudio and Its Procee 7
R Studio GUI
Steps or Procedure
Introduction
R is a free, open-source software and programming language
developed in 1995 at the University of Auckland as an
environment for statistical computing and graphics.
2
RStudio screen
3
RStudio Windows and Description
Workspace tab (1)
The workspace tab stores any object, value, function or
anything you create during your R session. In the example
below, if you click on the dotted squares you can see the data
on a screen to the left.
5
Workspace tab (2)
Here is another example on how the workspace looks like
when more objects are added. Notice that the data frame
house.pets is formed from different individual values or
vectors.
Click on the dotted square to look at the
dataset in a spreadsheet form.
History Tab
getwd()
# Changes the wd
setwd("C:/myfolder/data")
2
3
Every time you open RStudio, it goes to a default
directory. You can change the default to a folder
where you have your datafiles so you do not have
to do it every time. In the menu go to Tools-
>Options
4
R script (1)
The usual RStudio screen has four windows:
1. Console.
2. Workspace and history.
3. Files, plots, packages and help.
4. The R script(s) and data view.
The R script is where you keep a record of your work. For Stata users this
would be like the do-file, for SPSS users is like the syntax and for SAS
users the SAS program.
R script (2)
To create a new R script you can either go to File -> New -> R Script, or click on the
icon with the “+” sign and select “R Script”, or simply press Ctrl+Shift+N. Make
sure to save the script.
Befor
e
1
We are going to install the
package – rgl (useful to plot 3D
images). It does not come with
2 the original R install.
Click on “Install Packages”,
3 write the name in the pop-up
window and click on “Install”.
Afte r
Plots tab (1)
4
1
5
3D graphs
1
6
Resources
For R related tutorials and/or resources see the following
links: http://dss.princeton.edu/training/
http://libguides.princeton.edu/dss