Introduction to R

John Bastiaansen

What is R

Downloading and Installation

CRAN

Main website of the R project : http://www.r-project.org/

Download and Installation

Downloading R

For this course, R has been installed on your computers

Start R

When R is installed it comes with the program’s GUI (Graphical User Interface) which looks like this:

R GUI

We don’t use this GUI in our course, instead we use RStudio

RStudio : an Integrated Development Environment

Rstudio interface

Using R

You can use R as a simple calculator:

(1+3)* (7-3)
## [1] 16
1024/256
## [1] 4
5^2
## [1] 25
exp(pi)-pi
## [1] 19.9991

The working directory of R

The working directory is R’s default place to look for files, find it using function getwd:

getwd()
dir <- "~/Dropbox/Rcursus/mei2015/john/introduction/"
setwd(dir)
getwd()
## [1] "~/Dropbox/Rcursus/mei2015/john/introduction/"

The help system in R: general

Use the function help.start() to open a help browser page:

The help page

In RStudio the help pages open in the lower right panel

The help system in R: specific

Use the ? operator to open a help page on an object or function:

?print to open help on the print function:

R help

In RStudio the help pages open in the lower right panel and can be expanded to full screen view

References for learning R

Quitting R

Type q() and R will quit:

Quitting R

Exercises

Return to main page