Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

R Programming

INTRODUCTION & PRELIMINARIES

This slide deck is only for educational purpose.


Disclaimer
 This presentation is purely for academic purpose and does not carry any
commercial value.

 All images used in this presentation are property of respective image holders.
Images are used only for indicative purpose and does not carry any other
meaning. 2
Why R?
data manipulation, calculation and graphical display

 An effective data handling and storage facility


 A suite of operators for calculations on arrays, matrices and other
data types
 A large, coherent, integrated collection of intermediate tools for
WHY

data analysis
 Graphical facilities for data analysis
 Simple and effective programming language having conditionals,
loops, user defined functions and input and output facilities
3
Case Sensitivity and Expression
Elementary commands consist of either expressions or assignments.

R is case sensitive. If an expression is given as a


> xa <- 1 command, it is evaluated, printed
(unless specifically made invisible),
> XA <- 11 and the value is lost.
> xa
EXAMPLE

EXAMPLE
> XA > 1+2+3
> (11 * 8) + 12
An assignment also evaluates an
expression and passes the value
to a variable but the result is not
automatically printed.
Features of R
 Commands are separated either by a semi-colon (‘;’), or by a
newline.
 Elementary commands can be grouped together into one
compound expression by braces (‘{’ and ‘}’).
WHY

 Comments can be put almost anywhere, starting with a hashmark


(‘#’), everything to the end of the line is a comment.
 If a command is not complete at the end of a line, R will give a
different prompt, by default ‘ + ’ on second and subsequent lines
and continue to read input until the command is syntactically
complete.
5
GET & SET DIRECTORY
Features of R

# Get working directory

> getwd()

# Set working directory


WHY

> setwd("D:/PIBM/R Programming/Programs")

# Rune the program in the file

> source(‘P1.r’)

7
Q&A

You might also like