SlideShare a Scribd company logo
4/16/2020 R Programming Lab - 1 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 1/9
R - Notebook [LAB EXPERIMENTS DEMONSTRATION] ---------------Prepared by - Asst. Prof.
Ashwini Mathur(CSSP)- Jain University
Following Tasks to Perform:
1. Explore assignment operator.
2. Create vectors using c(), seq(), rep(), colon operator.
3. Create different matrices using matrix() operator and explore its row
s, columns, and diagonals.
4. Perform different basic operation of matrices on above created matric
es.
5. Create single and multidimensional arrays with array() command.
6. Explore length(), dim(), ncol(), nrow() operators on above matrices a
nd arrays.
7. Explore commands for Selecting and extracting elements from above mat
rices and arrays.
8. Explore logical operators from R programming language.
9. Remove elements from selected positions from a considered matrix.
Question -1: Explore Assignments Operators
In [4]:
Question 2. Arithmetic Operators : Addition, Substration, Multiplication and Division
20
30
x = 20 #assigned value to the variable x
x
y = 30 #assigned value to the variable y
y
4/16/2020 R Programming Lab - 1 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 2/9
In [5]:
Create vectors using c(), seq(), rep(), colon operator
In [8]:
Create different matrices using matrix() operator and explore its rows, columns, and
diagonals.
50
-10
600
0.666666666666667
100 200 300 400 500
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10
10 11 12 13 14 15 16 17 18 19 20
50 50 50 50 50 50 50 50 50 50
a = x+y # addition operator
a
b = x-y # substraction operator
b
c = x*y # Multiplication operator
c
d = x/y # Division operator
d
x = c(100,200,300,400,500) #creation of Vector
x #Print x
y = seq(1,10, by=0.5)
y #print y
z = 10:20
z #Print z
q = rep(50,10) #repeat(10 number 10 times)
q #
4/16/2020 R Programming Lab - 1 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 3/9
In [9]:
In [13]:
In [14]:
Perform different basic operation of matrices on above created matrices
A matrix: 4 × 4
of type int
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
A matrix:
3 × 3 of
type int
1 2 3
4 5 6
7 8 9
A matrix:
3 × 3 of
type int
1 4 7
2 5 8
3 6 9
x = matrix(1:16, nrow = 4, ncol = 4) # Create a matrix of dimension 3X3
x
y = matrix(1:9, nrow=3, byrow=TRUE) # fill matrix row-wise
y
z = matrix(1:9, nrow=3, byrow=FALSE) # fill matrix column-wise
z
4/16/2020 R Programming Lab - 1 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 4/9
In [16]:
In [17]:
Create single and multidimensional arrays with array() command
In [18]:
A
matrix:
3 × 2
of type
dbl
1 4
2 5
3 6
3 2
A matrix:
2 × 3 of
type dbl
1 2 3
4 5 6
2 3
2 9 3
10 16 17 13 11 15
x = cbind(c(1,2,3),c(4,5,6))
x
dim(x)
y = rbind(c(1,2,3),c(4,5,6))
y
dim(y)
# Create two vectors of different lengths.
vector1 <- c(2,9,3)
vector2 <- c(10,16,17,13,11,15)
vector1 #print
vector2
4/16/2020 R Programming Lab - 1 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 5/9
In [25]:
In [ ]:
Explore length(), dim(), ncol(), nrow() operators on above matrices and arrays.
, , 1
[,1] [,2] [,3]
[1,] 2 10 13
[2,] 9 16 11
[3,] 3 17 15
, , 2
[,1] [,2] [,3]
[1,] 2 10 13
[2,] 9 16 11
[3,] 3 17 15
# Take these vectors as input to the array.
result <- array(c(vector1,vector2),dim = c(3,3,2)) #Multi-dimension
print(result)
result <- array(c(vector1,vector2),dim = c(3)) #Single dimension
print(result)
4/16/2020 R Programming Lab - 1 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 6/9
In [19]:
In [ ]:
Explore commands for Selecting and extracting elements from above matrices and arrays.
In [21]:
A matrix: 10 × 10 of type int
1 11 21 31 41 51 61 71 81 91
2 12 22 32 42 52 62 72 82 92
3 13 23 33 43 53 63 73 83 93
4 14 24 34 44 54 64 74 84 94
5 15 25 35 45 55 65 75 85 95
6 16 26 36 46 56 66 76 86 96
7 17 27 37 47 57 67 77 87 97
8 18 28 38 48 58 68 78 88 98
9 19 29 39 49 59 69 79 89 99
10 20 30 40 50 60 70 80 90 100
100
10 10
A matrix:
3 × 3 of
type int
1 4 7
2 5 8
3 6 9
4
x = matrix(1:100, nrow = 10, ncol = 10)
x
length(x) #Length of the Matrix
dim(x) #Dimension of the given matrix
ncol(x) #Total number of columns in given matrix
nrow(x) #Total Number of Rows in Given Matrix
x = matrix(1:9, nrow = 3, ncol = 3)
x
x[1,2] #Selecting the element of First row and second column
4/16/2020 R Programming Lab - 1 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 7/9
In [22]:
In [30]:
In [23]:
In [32]:
Explore logical operators from R programming language.
In [33]:
In [34]:
In [35]:
In [36]:
9
1 2 3
2 5 8
13
10
FALSE TRUE TRUE FALSE
FALSE FALSE FALSE TRUE
FALSE
TRUE TRUE FALSE TRUE
x[3,3] #Selecting the element of third row and third column
x[,1] #Selection the 1st column
x[2,] #Selecting the 3rd row
y <- c(10,16,17,13,11,15)
y[4] #Selecting 4th element
y[1] #selecting the first element
x <- c(TRUE,FALSE,0,6)
y <- c(FALSE,TRUE,FALSE,TRUE)
!x #(Complement of x) Logical NOT
x&y #Element-wise logical AND
x&&y #Logical AND
x|y # Element Wise Logical OR
4/16/2020 R Programming Lab - 1 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 8/9
In [37]:
Remove elements from selected positions from a considered matrix.
In [38]:
In [39]:
TRUE
A matrix:
3 × 3 of
type int
1 4 7
2 5 8
3 6 9
A
matrix:
3 × 2
of type
int
1 4
2 5
3 6
A matrix:
3 × 3 of
type int
1 4 7
2 5 8
3 6 9
x||y #Logical OR
x = matrix(1:9, nrow = 3, ncol = 3)
x
x[,-3] #Remove 3rd Column
4/16/2020 R Programming Lab - 1 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 9/9
In [40]:
A matrix:
2 × 3 of
type int
1 4 7
2 5 8
x[-3,] #Remove 3rd Row

More Related Content

What's hot

Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
Dmitri Nesteruk
 
Dynamic allocation
Dynamic allocationDynamic allocation
Dynamic allocation
CGC Technical campus,Mohali
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
rumanatasnim415
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
rumanatasnim415
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
PyData
 
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPER
CLASS XII COMPUTER SCIENCE MONTHLY TEST  PAPERCLASS XII COMPUTER SCIENCE MONTHLY TEST  PAPER
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPER
Rc Os
 
The matplotlib Library
The matplotlib LibraryThe matplotlib Library
The matplotlib Library
Haim Michael
 
Seminar fp
Seminar fpSeminar fp
Heap sort &amp; bubble sort
Heap sort &amp; bubble sortHeap sort &amp; bubble sort
Heap sort &amp; bubble sort
Shanmuga Raju
 
Wcbpijwbpij new
Wcbpijwbpij newWcbpijwbpij new
Wcbpijwbpij new
Hanokh Aloni
 
Py9 3
Py9 3Py9 3
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
The Statistical and Applied Mathematical Sciences Institute
 
computer notes - Data Structures - 9
computer notes - Data Structures - 9computer notes - Data Structures - 9
computer notes - Data Structures - 9ecomputernotes
 
Tensorflow basics
Tensorflow basicsTensorflow basics
Tensorflow basics
IshaNemaCSPOcertifie
 
〇〇の常識は■■の非常識
〇〇の常識は■■の非常識〇〇の常識は■■の非常識
〇〇の常識は■■の非常識Yoichi Hirai
 
Matplotlib
MatplotlibMatplotlib
Matplotlib
Amir Shokri
 
Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocation
Grishma Rajput
 
Chapter 1 Basic Concepts
Chapter 1 Basic ConceptsChapter 1 Basic Concepts
Chapter 1 Basic Concepts
Hareem Aslam
 
Ss matlab solved
Ss matlab solvedSs matlab solved
Ss matlab solved
Vijendrasingh Rathor
 

What's hot (20)

Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 
Dynamic allocation
Dynamic allocationDynamic allocation
Dynamic allocation
 
Sample2
Sample2Sample2
Sample2
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
 
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPER
CLASS XII COMPUTER SCIENCE MONTHLY TEST  PAPERCLASS XII COMPUTER SCIENCE MONTHLY TEST  PAPER
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPER
 
The matplotlib Library
The matplotlib LibraryThe matplotlib Library
The matplotlib Library
 
Seminar fp
Seminar fpSeminar fp
Seminar fp
 
Heap sort &amp; bubble sort
Heap sort &amp; bubble sortHeap sort &amp; bubble sort
Heap sort &amp; bubble sort
 
Wcbpijwbpij new
Wcbpijwbpij newWcbpijwbpij new
Wcbpijwbpij new
 
Py9 3
Py9 3Py9 3
Py9 3
 
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
 
computer notes - Data Structures - 9
computer notes - Data Structures - 9computer notes - Data Structures - 9
computer notes - Data Structures - 9
 
Tensorflow basics
Tensorflow basicsTensorflow basics
Tensorflow basics
 
〇〇の常識は■■の非常識
〇〇の常識は■■の非常識〇〇の常識は■■の非常識
〇〇の常識は■■の非常識
 
Matplotlib
MatplotlibMatplotlib
Matplotlib
 
Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocation
 
Chapter 1 Basic Concepts
Chapter 1 Basic ConceptsChapter 1 Basic Concepts
Chapter 1 Basic Concepts
 
Ss matlab solved
Ss matlab solvedSs matlab solved
Ss matlab solved
 

Similar to R programming lab 1 - jupyter notebook

Introduction to Data Science With R Lab Record
Introduction to Data Science With R Lab RecordIntroduction to Data Science With R Lab Record
Introduction to Data Science With R Lab Record
Lakshmi Sarvani Videla
 
R tutorial for a windows environment
R tutorial for a windows environmentR tutorial for a windows environment
R tutorial for a windows environment
Yogendra Chaubey
 
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
The Statistical and Applied Mathematical Sciences Institute
 
R basics
R basicsR basics
R basics
Sagun Baijal
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlab
SalanSD
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
062MayankSinghal
 
2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors
krishna singh
 
Computer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdfComputer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdf
PranavAnil9
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
Manchireddy Reddy
 
Data Structures problems 2002
Data Structures problems 2002Data Structures problems 2002
Data Structures problems 2002
Sanjay Goel
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
ArchishaKhandareSS20
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
vikassingh569137
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.ppt
anshikagoel52
 
Informatics Practices (new) solution CBSE 2021, Compartment, improvement ex...
Informatics Practices (new) solution CBSE  2021, Compartment,  improvement ex...Informatics Practices (new) solution CBSE  2021, Compartment,  improvement ex...
Informatics Practices (new) solution CBSE 2021, Compartment, improvement ex...
FarhanAhmade
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programming
Yanchang Zhao
 
R programming lab 3 - jupyter notebook
R programming lab   3 - jupyter notebookR programming lab   3 - jupyter notebook
R programming lab 3 - jupyter notebook
Ashwini Mathur
 
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
The Statistical and Applied Mathematical Sciences Institute
 
Mmc manual
Mmc manualMmc manual
Mmc manual
Urvi Surat
 

Similar to R programming lab 1 - jupyter notebook (20)

Introduction to Data Science With R Lab Record
Introduction to Data Science With R Lab RecordIntroduction to Data Science With R Lab Record
Introduction to Data Science With R Lab Record
 
R tutorial for a windows environment
R tutorial for a windows environmentR tutorial for a windows environment
R tutorial for a windows environment
 
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
 
R basics
R basicsR basics
R basics
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlab
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
 
2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors
 
Computer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdfComputer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdf
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Data Structures problems 2002
Data Structures problems 2002Data Structures problems 2002
Data Structures problems 2002
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Lecture1 r
Lecture1 rLecture1 r
Lecture1 r
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.ppt
 
Informatics Practices (new) solution CBSE 2021, Compartment, improvement ex...
Informatics Practices (new) solution CBSE  2021, Compartment,  improvement ex...Informatics Practices (new) solution CBSE  2021, Compartment,  improvement ex...
Informatics Practices (new) solution CBSE 2021, Compartment, improvement ex...
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programming
 
C sharp chap6
C sharp chap6C sharp chap6
C sharp chap6
 
R programming lab 3 - jupyter notebook
R programming lab   3 - jupyter notebookR programming lab   3 - jupyter notebook
R programming lab 3 - jupyter notebook
 
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
 
Mmc manual
Mmc manualMmc manual
Mmc manual
 

More from Ashwini Mathur

S3 classes and s4 classes
S3 classes and s4 classesS3 classes and s4 classes
S3 classes and s4 classes
Ashwini Mathur
 
Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r
Ashwini Mathur
 
Rpy2 demonstration
Rpy2 demonstrationRpy2 demonstration
Rpy2 demonstration
Ashwini Mathur
 
Rpy package
Rpy packageRpy package
Rpy package
Ashwini Mathur
 
R programming lab 2 - jupyter notebook
R programming lab   2 - jupyter notebookR programming lab   2 - jupyter notebook
R programming lab 2 - jupyter notebook
Ashwini Mathur
 
R for statistics session 1
R for statistics session 1R for statistics session 1
R for statistics session 1
Ashwini Mathur
 
R for statistics 2
R for statistics 2R for statistics 2
R for statistics 2
Ashwini Mathur
 
Play with matrix in r
Play with matrix in rPlay with matrix in r
Play with matrix in r
Ashwini Mathur
 
Object oriented programming in r
Object oriented programming in r Object oriented programming in r
Object oriented programming in r
Ashwini Mathur
 
Linear programming optimization in r
Linear programming optimization in r Linear programming optimization in r
Linear programming optimization in r
Ashwini Mathur
 
Introduction to python along with the comparitive analysis with r
Introduction to python   along with the comparitive analysis with r Introduction to python   along with the comparitive analysis with r
Introduction to python along with the comparitive analysis with r
Ashwini Mathur
 
Example 2 summerization notes for descriptive statistics using r
Example   2    summerization notes for descriptive statistics using r Example   2    summerization notes for descriptive statistics using r
Example 2 summerization notes for descriptive statistics using r
Ashwini Mathur
 
Descriptive statistics assignment
Descriptive statistics assignment Descriptive statistics assignment
Descriptive statistics assignment
Ashwini Mathur
 
Descriptive analytics in r programming language
Descriptive analytics in r programming languageDescriptive analytics in r programming language
Descriptive analytics in r programming language
Ashwini Mathur
 
Data analysis for covid 19
Data analysis for covid 19Data analysis for covid 19
Data analysis for covid 19
Ashwini Mathur
 
Correlation and linear regression
Correlation and linear regression Correlation and linear regression
Correlation and linear regression
Ashwini Mathur
 
Calling c functions from r programming unit 5
Calling c functions from r programming    unit 5Calling c functions from r programming    unit 5
Calling c functions from r programming unit 5
Ashwini Mathur
 
Anova (analysis of variance) test
Anova (analysis of variance) test Anova (analysis of variance) test
Anova (analysis of variance) test
Ashwini Mathur
 

More from Ashwini Mathur (18)

S3 classes and s4 classes
S3 classes and s4 classesS3 classes and s4 classes
S3 classes and s4 classes
 
Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r
 
Rpy2 demonstration
Rpy2 demonstrationRpy2 demonstration
Rpy2 demonstration
 
Rpy package
Rpy packageRpy package
Rpy package
 
R programming lab 2 - jupyter notebook
R programming lab   2 - jupyter notebookR programming lab   2 - jupyter notebook
R programming lab 2 - jupyter notebook
 
R for statistics session 1
R for statistics session 1R for statistics session 1
R for statistics session 1
 
R for statistics 2
R for statistics 2R for statistics 2
R for statistics 2
 
Play with matrix in r
Play with matrix in rPlay with matrix in r
Play with matrix in r
 
Object oriented programming in r
Object oriented programming in r Object oriented programming in r
Object oriented programming in r
 
Linear programming optimization in r
Linear programming optimization in r Linear programming optimization in r
Linear programming optimization in r
 
Introduction to python along with the comparitive analysis with r
Introduction to python   along with the comparitive analysis with r Introduction to python   along with the comparitive analysis with r
Introduction to python along with the comparitive analysis with r
 
Example 2 summerization notes for descriptive statistics using r
Example   2    summerization notes for descriptive statistics using r Example   2    summerization notes for descriptive statistics using r
Example 2 summerization notes for descriptive statistics using r
 
Descriptive statistics assignment
Descriptive statistics assignment Descriptive statistics assignment
Descriptive statistics assignment
 
Descriptive analytics in r programming language
Descriptive analytics in r programming languageDescriptive analytics in r programming language
Descriptive analytics in r programming language
 
Data analysis for covid 19
Data analysis for covid 19Data analysis for covid 19
Data analysis for covid 19
 
Correlation and linear regression
Correlation and linear regression Correlation and linear regression
Correlation and linear regression
 
Calling c functions from r programming unit 5
Calling c functions from r programming    unit 5Calling c functions from r programming    unit 5
Calling c functions from r programming unit 5
 
Anova (analysis of variance) test
Anova (analysis of variance) test Anova (analysis of variance) test
Anova (analysis of variance) test
 

Recently uploaded

Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 

Recently uploaded (20)

Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 

R programming lab 1 - jupyter notebook

  • 1. 4/16/2020 R Programming Lab - 1 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 1/9 R - Notebook [LAB EXPERIMENTS DEMONSTRATION] ---------------Prepared by - Asst. Prof. Ashwini Mathur(CSSP)- Jain University Following Tasks to Perform: 1. Explore assignment operator. 2. Create vectors using c(), seq(), rep(), colon operator. 3. Create different matrices using matrix() operator and explore its row s, columns, and diagonals. 4. Perform different basic operation of matrices on above created matric es. 5. Create single and multidimensional arrays with array() command. 6. Explore length(), dim(), ncol(), nrow() operators on above matrices a nd arrays. 7. Explore commands for Selecting and extracting elements from above mat rices and arrays. 8. Explore logical operators from R programming language. 9. Remove elements from selected positions from a considered matrix. Question -1: Explore Assignments Operators In [4]: Question 2. Arithmetic Operators : Addition, Substration, Multiplication and Division 20 30 x = 20 #assigned value to the variable x x y = 30 #assigned value to the variable y y
  • 2. 4/16/2020 R Programming Lab - 1 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 2/9 In [5]: Create vectors using c(), seq(), rep(), colon operator In [8]: Create different matrices using matrix() operator and explore its rows, columns, and diagonals. 50 -10 600 0.666666666666667 100 200 300 400 500 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10 10 11 12 13 14 15 16 17 18 19 20 50 50 50 50 50 50 50 50 50 50 a = x+y # addition operator a b = x-y # substraction operator b c = x*y # Multiplication operator c d = x/y # Division operator d x = c(100,200,300,400,500) #creation of Vector x #Print x y = seq(1,10, by=0.5) y #print y z = 10:20 z #Print z q = rep(50,10) #repeat(10 number 10 times) q #
  • 3. 4/16/2020 R Programming Lab - 1 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 3/9 In [9]: In [13]: In [14]: Perform different basic operation of matrices on above created matrices A matrix: 4 × 4 of type int 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 A matrix: 3 × 3 of type int 1 2 3 4 5 6 7 8 9 A matrix: 3 × 3 of type int 1 4 7 2 5 8 3 6 9 x = matrix(1:16, nrow = 4, ncol = 4) # Create a matrix of dimension 3X3 x y = matrix(1:9, nrow=3, byrow=TRUE) # fill matrix row-wise y z = matrix(1:9, nrow=3, byrow=FALSE) # fill matrix column-wise z
  • 4. 4/16/2020 R Programming Lab - 1 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 4/9 In [16]: In [17]: Create single and multidimensional arrays with array() command In [18]: A matrix: 3 × 2 of type dbl 1 4 2 5 3 6 3 2 A matrix: 2 × 3 of type dbl 1 2 3 4 5 6 2 3 2 9 3 10 16 17 13 11 15 x = cbind(c(1,2,3),c(4,5,6)) x dim(x) y = rbind(c(1,2,3),c(4,5,6)) y dim(y) # Create two vectors of different lengths. vector1 <- c(2,9,3) vector2 <- c(10,16,17,13,11,15) vector1 #print vector2
  • 5. 4/16/2020 R Programming Lab - 1 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 5/9 In [25]: In [ ]: Explore length(), dim(), ncol(), nrow() operators on above matrices and arrays. , , 1 [,1] [,2] [,3] [1,] 2 10 13 [2,] 9 16 11 [3,] 3 17 15 , , 2 [,1] [,2] [,3] [1,] 2 10 13 [2,] 9 16 11 [3,] 3 17 15 # Take these vectors as input to the array. result <- array(c(vector1,vector2),dim = c(3,3,2)) #Multi-dimension print(result) result <- array(c(vector1,vector2),dim = c(3)) #Single dimension print(result)
  • 6. 4/16/2020 R Programming Lab - 1 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 6/9 In [19]: In [ ]: Explore commands for Selecting and extracting elements from above matrices and arrays. In [21]: A matrix: 10 × 10 of type int 1 11 21 31 41 51 61 71 81 91 2 12 22 32 42 52 62 72 82 92 3 13 23 33 43 53 63 73 83 93 4 14 24 34 44 54 64 74 84 94 5 15 25 35 45 55 65 75 85 95 6 16 26 36 46 56 66 76 86 96 7 17 27 37 47 57 67 77 87 97 8 18 28 38 48 58 68 78 88 98 9 19 29 39 49 59 69 79 89 99 10 20 30 40 50 60 70 80 90 100 100 10 10 A matrix: 3 × 3 of type int 1 4 7 2 5 8 3 6 9 4 x = matrix(1:100, nrow = 10, ncol = 10) x length(x) #Length of the Matrix dim(x) #Dimension of the given matrix ncol(x) #Total number of columns in given matrix nrow(x) #Total Number of Rows in Given Matrix x = matrix(1:9, nrow = 3, ncol = 3) x x[1,2] #Selecting the element of First row and second column
  • 7. 4/16/2020 R Programming Lab - 1 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 7/9 In [22]: In [30]: In [23]: In [32]: Explore logical operators from R programming language. In [33]: In [34]: In [35]: In [36]: 9 1 2 3 2 5 8 13 10 FALSE TRUE TRUE FALSE FALSE FALSE FALSE TRUE FALSE TRUE TRUE FALSE TRUE x[3,3] #Selecting the element of third row and third column x[,1] #Selection the 1st column x[2,] #Selecting the 3rd row y <- c(10,16,17,13,11,15) y[4] #Selecting 4th element y[1] #selecting the first element x <- c(TRUE,FALSE,0,6) y <- c(FALSE,TRUE,FALSE,TRUE) !x #(Complement of x) Logical NOT x&y #Element-wise logical AND x&&y #Logical AND x|y # Element Wise Logical OR
  • 8. 4/16/2020 R Programming Lab - 1 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 8/9 In [37]: Remove elements from selected positions from a considered matrix. In [38]: In [39]: TRUE A matrix: 3 × 3 of type int 1 4 7 2 5 8 3 6 9 A matrix: 3 × 2 of type int 1 4 2 5 3 6 A matrix: 3 × 3 of type int 1 4 7 2 5 8 3 6 9 x||y #Logical OR x = matrix(1:9, nrow = 3, ncol = 3) x x[,-3] #Remove 3rd Column
  • 9. 4/16/2020 R Programming Lab - 1 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 1.ipynb 9/9 In [40]: A matrix: 2 × 3 of type int 1 4 7 2 5 8 x[-3,] #Remove 3rd Row