You are on page 1of 11

Directory

 Working directory
Path where the current plots, scripts are running.

 Get the working directory


getwd()

 Set the working directory


setwd(path)

R programming - Pratik Gadia


Objects in R

 Class
 Blueprint Class

 Object
 Occurrence
Object1 Object2

Object3

R programming - Pratik Gadia


Variable

 Name given to a memory location


 Can hold value
x y
 Carry out manipulations
10 … 20 … …

10826 10828 10830 10832 10834

Rules
 Can include alphanumeric characters, dot and underscore
 Start with a letter OR a dot not followed by a number

R programming - Pratik Gadia


Variable

Valid examples:
 sales = 1000
 .q2_sales = 1000

Invalid examples:
 3sales = 1000
 __sales = 2000
 .4q_sales = 2000

R programming - Pratik Gadia


Variable

Identify valid and invalid variables in R

 Sales_Q1
 Sales#Q1
 .salesq1
 .2019sales.data

R programming - Pratik Gadia


Comment

 Used to add a note


 Ignored by interpreter

R programming - Pratik Gadia


Data Structures

Restricts the variable to hold a value of certain type


Atomic Collection

Numeric Vector

Integer List

Character Matrix

Logical DataFrame

Complex

R programming - Pratik Gadia


Atomic

What are the examples of some of the values that can be


classified under fundamental data types?

 Numeric
 Integer
 Character
 Logical

R programming - Pratik Gadia


Collection

 Ability to store multiple elements in a single object


 Single or multi dimensional

R programming - Pratik Gadia


Vector

 One dimensional collection of homogeneous values

Vector1 Vector2
Quarter Sales

Q1 2500000

Q2 2200000

Q3 2300000

R programming - Pratik Gadia


Vector

 Create a vector
 Access elements
 Manipulation
 Sorting
 Appending an element
 Removing an element
 Delete a vector

R programming - Pratik Gadia

You might also like