SlideShare a Scribd company logo
Prof. Neeraj Bhargava
Pramod Singh Rathore
Department of Computer Science
School of Engineering & System Sciences,
MDS University Ajmer, Rajasthan, India
1
Data types in R
Session Objectives
 What is data type in R ?
 How to handle data types in R
2
Data types in R
3
Data types can be listed as
• Vectors
• Lists
• Matrices
• Data Frames
• Factors
Vectors
4
Vectors is a list of main components which have same data types
Vectors can be define by using c() in R
Members in a vectors are officially called components
Vectors scan be of integer, numeric, character or logical types.
Vectors Index
5
Values in a vector can be retrieved by declaring an index inside a single
square bracket[]
Eg
If 3rd element Is retrieved
C[3]
C[3:5]
If the index is negative , it would strip the member whose position has the
same absolute value a s the negative index
Vectors Index
6
Numeric vector index: A new vector can be sliced from a give n vector with a
numeric index, vector, which consist of member positons of the original vector
to be retrieved
Eg
Name of vector[2,3]
Logical vector index : A new vector can be sliced from a given vector with a
logical index vector, which ahs the same is length as the original vector. Its
members are TRUE if the corresponding members in the original vector are to
be includes in the slice, and FALSE if otherwise
Matrics
7
A Matrix is a collection of data elements arranged in a two dimensional
rectangular layout. The following is an example of a matrix with 2 rows and 3
columns
[2 34 6]
All the elements of matrices has to be af same type
Lists
8
List is similar as vector
It is a data structure have components of mixed data types
Data frames
9
A data frame is used fro storing data tables
It is a special case of list which as each components of equal length
Each component form the column and contents of the components form the
rows
Data frame can be define by data.frame() function
Factors
10
Factor is a data structure used for fields that takes only predefined, finite
number of values (catergorialc data)
Factor variable will always have levels
While using data.frame() all the character data are converted into factor
How to handle vector in R
11
c(2,3,4) output : 2 3 4
Class(c(2,3,4)) numeric
C(2,3,”pramod”) “2” “3” “pramod”
class(C(2,3,”pramod”)) character
Length(c(2,3,4)) 3
a = c(2,3,4)
b= c(“a”,”b”,”c”)
vec=c(a,b) “2”,”3”,”4”,”a”,”b”,”c”
class(vec) character
Class(a) numeric
How to handle vector in R
12
A= c(1,2,3,4)
b= c(-1,-2,-3,-4)
Vect=a+b 0 0 0 0
v1=c(1,2,3)
v2=c(4,5,6,7)
v3=v1+v2 warning message
5 7 9 8 recycling rule
How to handle vector in R
13
v4= c(1:10)
v4[5] 5
V4[-5] 1 2 3 4 6 7 8 9 10
V4(3:5) 3 4 5
V4[c(3:5),10] 3 4 5 10 range indexing
Assignment 1
 What is data types in R?
 Explain each data type with suitable example
14
Queries ????
15
16

More Related Content

PDF
Data structures; arrays By ZAK
PPTX
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
PPT
Introductiont To Aray,Tree,Stack, Queue
PPTX
Introduction to data structure
PPTX
Data Structure & Algorithms | Computer Science
PPTX
R data-structures-3
PPTX
R data structures-2
PPT
Data structure
Data structures; arrays By ZAK
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
Introductiont To Aray,Tree,Stack, Queue
Introduction to data structure
Data Structure & Algorithms | Computer Science
R data-structures-3
R data structures-2
Data structure

What's hot (20)

PPTX
R Data Structures (Part 1)
PDF
Introduction of data structures and algorithms
PPTX
Introduction To Data Structures.
PPT
data structure
PDF
Data structure using c++
PDF
Data structure
PPTX
Data structures
PPTX
Computer Science-Data Structures :Abstract DataType (ADT)
PPT
Introduction to data structure
PDF
Data Structures
PPTX
DATA STRUCTURE
PPT
Abstract data types
PPT
Abstract data types (adt) intro to data structure part 2
PPTX
Presentation on Data Structure
PDF
M v bramhananda reddy dsa complete notes
PPT
Chapter 8: tree data structure
PPT
Lecture 1 data structures and algorithms
DOCX
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
PPTX
PDF
Ii pu cs practical viva voce questions
R Data Structures (Part 1)
Introduction of data structures and algorithms
Introduction To Data Structures.
data structure
Data structure using c++
Data structure
Data structures
Computer Science-Data Structures :Abstract DataType (ADT)
Introduction to data structure
Data Structures
DATA STRUCTURE
Abstract data types
Abstract data types (adt) intro to data structure part 2
Presentation on Data Structure
M v bramhananda reddy dsa complete notes
Chapter 8: tree data structure
Lecture 1 data structures and algorithms
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Ii pu cs practical viva voce questions
Ad

Similar to Data types in r (20)

PPTX
Handle list in r
PPTX
Control statements
PPTX
R data types
PPTX
PDF
Expository data analysis aand visualization-1.pdf
PDF
Expository data analysis aand visualization-1.pdf
PDF
23 data-structures
PPTX
R programming Fundamentals
PDF
Data Types and Structures in R
PDF
Expository data analysis and visualization-1.pdf
PDF
Expository data analysis and visualization-1.pdf
PDF
R Programing language Notes Unit 5 Data Viz in R
PDF
R training2
PPTX
R교육1
PPTX
2. R-basics, Vectors, Arrays, Matrices, Factors
PDF
R language, an introduction
PDF
3 Data Structure in R
PDF
R training3
PPTX
Unit-5 BDS.pptx on basics of data science
PPTX
Introduction to R - Basics of R programming, Data structures.pptx
Handle list in r
Control statements
R data types
Expository data analysis aand visualization-1.pdf
Expository data analysis aand visualization-1.pdf
23 data-structures
R programming Fundamentals
Data Types and Structures in R
Expository data analysis and visualization-1.pdf
Expository data analysis and visualization-1.pdf
R Programing language Notes Unit 5 Data Viz in R
R training2
R교육1
2. R-basics, Vectors, Arrays, Matrices, Factors
R language, an introduction
3 Data Structure in R
R training3
Unit-5 BDS.pptx on basics of data science
Introduction to R - Basics of R programming, Data structures.pptx
Ad

More from Pramod Rathore (20)

PPTX
Restoration by spatial filtering
PPTX
Image restoration
PPTX
Homomorphic filtering
PPTX
Sharpening filtering
PPTX
Image enhancement in frequency domain
PPTX
Image enhancement in fourier transform part ii
PPTX
Image enhancement in fourier transform
PPTX
Basic image operation
PPTX
How to handling strings in r
PPTX
Smoothing spatial filtering
PPTX
Spatial filtering
PPTX
6.histogram processing
PPTX
5.image enhancement in spatial domain copy - copy
PPTX
4.image enhancement in spatial domain copy
PPTX
Issues in machine learning
PPTX
R programming
PPTX
Image enhancement in spatial domain
PPTX
2.image enhancement
PPTX
1.introduction to data science
Restoration by spatial filtering
Image restoration
Homomorphic filtering
Sharpening filtering
Image enhancement in frequency domain
Image enhancement in fourier transform part ii
Image enhancement in fourier transform
Basic image operation
How to handling strings in r
Smoothing spatial filtering
Spatial filtering
6.histogram processing
5.image enhancement in spatial domain copy - copy
4.image enhancement in spatial domain copy
Issues in machine learning
R programming
Image enhancement in spatial domain
2.image enhancement
1.introduction to data science

Recently uploaded (20)

PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Computing-Curriculum for Schools in Ghana
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
RMMM.pdf make it easy to upload and study
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Structure & Organelles in detailed.
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPH.pptx obstetrics and gynecology in nursing
Microbial disease of the cardiovascular and lymphatic systems
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Pharma ospi slides which help in ospi learning
Computing-Curriculum for Schools in Ghana
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
O7-L3 Supply Chain Operations - ICLT Program
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Cell Types and Its function , kingdom of life
RMMM.pdf make it easy to upload and study
O5-L3 Freight Transport Ops (International) V1.pdf
01-Introduction-to-Information-Management.pdf
Classroom Observation Tools for Teachers
Cell Structure & Organelles in detailed.
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Insiders guide to clinical Medicine.pdf
Final Presentation General Medicine 03-08-2024.pptx

Data types in r

  • 1. Prof. Neeraj Bhargava Pramod Singh Rathore Department of Computer Science School of Engineering & System Sciences, MDS University Ajmer, Rajasthan, India 1 Data types in R
  • 2. Session Objectives  What is data type in R ?  How to handle data types in R 2
  • 3. Data types in R 3 Data types can be listed as • Vectors • Lists • Matrices • Data Frames • Factors
  • 4. Vectors 4 Vectors is a list of main components which have same data types Vectors can be define by using c() in R Members in a vectors are officially called components Vectors scan be of integer, numeric, character or logical types.
  • 5. Vectors Index 5 Values in a vector can be retrieved by declaring an index inside a single square bracket[] Eg If 3rd element Is retrieved C[3] C[3:5] If the index is negative , it would strip the member whose position has the same absolute value a s the negative index
  • 6. Vectors Index 6 Numeric vector index: A new vector can be sliced from a give n vector with a numeric index, vector, which consist of member positons of the original vector to be retrieved Eg Name of vector[2,3] Logical vector index : A new vector can be sliced from a given vector with a logical index vector, which ahs the same is length as the original vector. Its members are TRUE if the corresponding members in the original vector are to be includes in the slice, and FALSE if otherwise
  • 7. Matrics 7 A Matrix is a collection of data elements arranged in a two dimensional rectangular layout. The following is an example of a matrix with 2 rows and 3 columns [2 34 6] All the elements of matrices has to be af same type
  • 8. Lists 8 List is similar as vector It is a data structure have components of mixed data types
  • 9. Data frames 9 A data frame is used fro storing data tables It is a special case of list which as each components of equal length Each component form the column and contents of the components form the rows Data frame can be define by data.frame() function
  • 10. Factors 10 Factor is a data structure used for fields that takes only predefined, finite number of values (catergorialc data) Factor variable will always have levels While using data.frame() all the character data are converted into factor
  • 11. How to handle vector in R 11 c(2,3,4) output : 2 3 4 Class(c(2,3,4)) numeric C(2,3,”pramod”) “2” “3” “pramod” class(C(2,3,”pramod”)) character Length(c(2,3,4)) 3 a = c(2,3,4) b= c(“a”,”b”,”c”) vec=c(a,b) “2”,”3”,”4”,”a”,”b”,”c” class(vec) character Class(a) numeric
  • 12. How to handle vector in R 12 A= c(1,2,3,4) b= c(-1,-2,-3,-4) Vect=a+b 0 0 0 0 v1=c(1,2,3) v2=c(4,5,6,7) v3=v1+v2 warning message 5 7 9 8 recycling rule
  • 13. How to handle vector in R 13 v4= c(1:10) v4[5] 5 V4[-5] 1 2 3 4 6 7 8 9 10 V4(3:5) 3 4 5 V4[c(3:5),10] 3 4 5 10 range indexing
  • 14. Assignment 1  What is data types in R?  Explain each data type with suitable example 14
  • 16. 16