SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (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
 

Ähnlich wie 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 RecordLakshmi Sarvani Videla
 
R tutorial for a windows environment
R tutorial for a windows environmentR tutorial for a windows environment
R tutorial for a windows environmentYogendra Chaubey
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlabSalanSD
 
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, Factorskrishna 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 .pdfPranavAnil9
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentationManchireddy Reddy
 
Data Structures problems 2002
Data Structures problems 2002Data Structures problems 2002
Data Structures problems 2002Sanjay Goel
 
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.pptanshikagoel52
 
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-programmingYanchang Zhao
 
R programming lab 3 - jupyter notebook
R programming lab   3 - jupyter notebookR programming lab   3 - jupyter notebook
R programming lab 3 - jupyter notebookAshwini Mathur
 

Ähnlich wie 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
 

Mehr von Ashwini Mathur

S3 classes and s4 classes
S3 classes and s4 classesS3 classes and s4 classes
S3 classes and s4 classesAshwini 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
 
R programming lab 2 - jupyter notebook
R programming lab   2 - jupyter notebookR programming lab   2 - jupyter notebook
R programming lab 2 - jupyter notebookAshwini Mathur
 
R for statistics session 1
R for statistics session 1R for statistics session 1
R for statistics session 1Ashwini 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 languageAshwini Mathur
 
Data analysis for covid 19
Data analysis for covid 19Data analysis for covid 19
Data analysis for covid 19Ashwini 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 5Ashwini Mathur
 
Anova (analysis of variance) test
Anova (analysis of variance) test Anova (analysis of variance) test
Anova (analysis of variance) test Ashwini Mathur
 

Mehr von 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
 

Kürzlich hochgeladen

FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 

Kürzlich hochgeladen (20)

FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 

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