SlideShare a Scribd company logo
Vector
with regularly spaced numbers
> 1:10
[1] 1 2 3
> seq(1,10)
[1] 1 2 3
> seq(1,10,2)
[1] 1 3 5 7 9

4

5

6

7

8

9 10

4

5

6

7

8

9 10

• We have used both “:” operator and seq command
• Note the last command where we have used “2” as
step, which is the “by” argument of the seq command
Try some sequence
or seq commands ….
> seq(0,1, length=11)
[1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
> seq(4,10,by=0.5)
[1] 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0
> seq(4,10,0.5)
[1] 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0

8.5

9.0

9.5 10.0

8.5

9.0

9.5 10.0

> seq(2,8,0.3)
[1] 2.0 2.3 2.6 2.9 3.2 3.5 3.8 4.1 4.4 4.7 5.0 5.3 5.6 5.9 6.2 6.5 6.8 7.1 7.4
7.7
[21] 8.0
> seq.int(2,8,0.3)
[1] 2.0 2.3 2.6 2.9 3.2 3.5 3.8 4.1 4.4 4.7 5.0 5.3 5.6 5.9 6.2 6.5 6.8 7.1 7.4
7.7
[21] 8.0
> seq(2,8,length.out=10)
[1] 2.000000 2.666667 3.333333 4.000000 4.666667 5.333333 6.000000 6.666667
7.333333
[10] 8.000000
Try more seq commands ….
> seq(1,5,0.3)
[1] 1.0 1.3 1.6 1.9 2.2 2.5 2.8 3.1 3.4 3.7 4.0 4.3 4.6 4.9
> pi:6
[1] 3.141593 4.141593 5.141593
> 6:pi
[1] 6 5 4
> 10:-2
[1] 10 9 8 7 6 5 4 3 2 1 0 -1 -2
> -7:8
[1] -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8

• You can generate decreasing sequence
• Try generating a sequence of negative numbers
Think and try …...
Generate a sequence of the following numbers:
0.0 0.2 0.4 0.6 0.8 1.0 1.0 2.0 3.0
6.0 7.0 8.0 9.0 10.0 100.0

4.0

Hints
• You have to use more than one sequence.
• But how will you include “100”?

5.0
Think and try ….. Possible Solution
Generate a sequence of the following numbers:
0.0 0.2 0.4 0.6 0.8 1.0 1.0 2.0 3.0
6.0 7.0 8.0 9.0 10.0 100.0

> seq(0, 1, length=6)
[1] 0.0 0.2 0.4 0.6 0.8 1.0
> seq.1<-seq(0, 1, length=6)
> c(seq.1,1:10,100)
[1]
0.0
0.2
0.4
0.6
[14]
8.0
9.0 10.0 100.0

0.8

1.0

1.0

2.0

3.0

4.0

4.0

5.0

5.0

6.0

7.0
Try replicate or rep command
> rep(1:5,2)
[1] 1 2 3 4 5 1 2 3 4 5
> rep(1:5, length=12)
[1] 1 2 3 4 5 1 2 3 4 5 1 2

> rep(c('one', 'two'), c(6, 3))
[1] "one" "one" "one" "one" "one" "one" "two" "two" "two"

Now enter help(rep) command and try the examples
Try replicate or rep command
> rep(1:4, each = 2)
[1] 1 1 2 2 3 3 4 4
> rep(1:4, c(2,2,2,2))
[1] 1 1 2 2 3 3 4 4
> rep(5:8, c(2,1,2,1))
[1] 5 5 6 7 7 8
> rep(1:4, each = 2, len = 4)
[1] 1 1 2 2

Hope you are enjoying as we go….. Have you noted the
arguments “each” and “len”gth? Now note the “times”
argument
> rep(1:4, each = 2, times = 3)
[1] 1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4
Try Histogram….
Suppose the top 25 ranked movies made the following gross receipts
for a Week:
29.6 28.2 19.6 13.7 13.0 7.8 3.4 2.0 1.9 1.0 0.7 0.4 0.4 0.3
0.3 0.3 0.3 0.3 0.2 0.2 0.2 0.1 0.1 0.1 0.1 0.1
Scan the data and then draw some histograms.
> x
[1] 29.6 28.2 19.6 13.7 13.0
0.4 0.4 0.3 0.3 0.3
[17] 0.3 0.3 0.2 0.2 0.2
> receipts<-x
> hist(receipts)

7.8

3.4

2.0

1.9

1.0

0.1

0.1

0.1

0.1

0.1

0.7
Try Histogram….
Suppose the top 25 ranked movies made the following gross receipts
for a Week:
29.6 28.2 19.6 13.7 13.0 7.8 3.4 2.0 1.9 1.0 0.7 0.4 0.4 0.3
0.3 0.3 0.3 0.3 0.2 0.2 0.2 0.1 0.1 0.1 0.1 0.1
Now try better histograms ….
Add colour, change colour, add title for the histogram, add title
for x-axis and then y-axis
> hist(receipts, col="red2")
> hist(receipts, col="red4")
> hist(receipts, col="red2",main="Gross Receipts for
first 25 ranked movies")
> hist(receipts, col="red2",main="Gross Receipts for
first 25 ranked movies",xlab="receipts in a week")
> hist(receipts, col="red2",main="Gross Receipts for
first 25 ranked movies",xlab="receipts in a
week",ylab="count of movies")
Now try better histograms ….
Your new histogram should look like this
Now try better histograms ….
Now put the range for x-axis and y-axis
> hist(receipts, col="red2",main="Gross Receipts for first 25
ranked movies",xlab="receipts in a week",ylab="count of
movies",xlim=c(0.1,35),ylim=c(0,25))
Now more about histograms ….
Now try breaks=….
What is “breaks”?
> hist(receipts,breaks=3,col="red2",main="Gross Receipts
for first 25 ranked movies",xlab="receipts in a
week",ylab="count of movies")

Remember:
Breaks is just a
suggestion to R
Now more about breaks ….
“breaks” can also specify the actual break points
in a histogram
> hist(receipts,breaks=c(0,1,2,3,4,5,10,20,max(x)),col="violetred")

Note the break points
Summary and Fivenum
Suppose, CEO yearly compensations are sampled and the
following are found (in millions).
12 0.4 5 2 50 8 3 1 4 0.25
> sals
[1] 12.00 0.40 5.00 2.00 50.00 8.00 3.00 1.00 4.00 0.25
> mean(sals) # the average
[1] 8.565
> var(sals) # the variance
[1] 225.5145
> sd(sals) # the standard deviation
[1] 15.01714
> median(sals) # the median
[1] 3.5
> summary(sals)
Min. 1st Qu. Median
Mean 3rd Qu.
Max.
0.250
1.250
3.500
8.565
7.250 50.000
> fivenum(sals) # min, lower hinge, Median, upper hinge, max
[1] 0.25 1.00 3.50 8.00 50.00
> quantile(sals)
0%
25%
50%
75% 100%
0.25 1.25 3.50 7.25 50.00
Important: Difference between
Fivenum and Quantiles
Difference between
Fivenum and Quantile:
Lower and Upper Hinge
The sorted data:
0.25 0.4 1 2 3 3.5 4 5 8 12 50
Median = 3.5

• The lower hinge is the median of all the data to the left of
the median (3.5), not counting this particular data point (if it
is one.)
• The upper hinge is similarly defined.

More Related Content

What's hot

מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
   מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה    מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
Igor Kleiner
 
Convolutional Neural Network
Convolutional Neural NetworkConvolutional Neural Network
Convolutional Neural Network
Jun Young Park
 
Python Basics #1
Python Basics #1Python Basics #1
Python Basics #1
Roland Askew
 
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlowWrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
WrangleConf
 
Pandas+postgre sql 實作 with code
Pandas+postgre sql 實作 with codePandas+postgre sql 實作 with code
Pandas+postgre sql 實作 with code
Tim Hong
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
Svet Ivantchev
 
Python modulesfinal
Python modulesfinalPython modulesfinal
Python modulesfinal
Saraswathi Murugan
 
The Ring programming language version 1.5.3 book - Part 61 of 184
The Ring programming language version 1.5.3 book - Part 61 of 184The Ring programming language version 1.5.3 book - Part 61 of 184
The Ring programming language version 1.5.3 book - Part 61 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84
Mahmoud Samir Fayed
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10
Mark Chang
 
response of system for given transfer function
response of system for given transfer functionresponse of system for given transfer function
response of system for given transfer function
Denishthummar
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changeshayato
 
The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.5.4 book - Part 52 of 185The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.5.4 book - Part 52 of 185
Mahmoud Samir Fayed
 
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий КуриловАсинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Yandex
 
Lập trình Python cơ bản
Lập trình Python cơ bảnLập trình Python cơ bản
Lập trình Python cơ bản
Nguyen Thi Lan Phuong
 
The secrets of inverse brogramming
The secrets of inverse brogrammingThe secrets of inverse brogramming
The secrets of inverse brogramming
Richie Cotton
 
Program Language - Fall 2013
Program Language - Fall 2013 Program Language - Fall 2013
Program Language - Fall 2013
Yun-Yan Chi
 
Math 3-H6
Math 3-H6Math 3-H6
Math 3-H6
jjlendaya
 
How fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practiceHow fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practice
Tobias Pfeiffer
 

What's hot (20)

מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
   מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה    מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
 
Calvix python
Calvix pythonCalvix python
Calvix python
 
Convolutional Neural Network
Convolutional Neural NetworkConvolutional Neural Network
Convolutional Neural Network
 
Python Basics #1
Python Basics #1Python Basics #1
Python Basics #1
 
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlowWrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
 
Pandas+postgre sql 實作 with code
Pandas+postgre sql 實作 with codePandas+postgre sql 實作 with code
Pandas+postgre sql 實作 with code
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
 
Python modulesfinal
Python modulesfinalPython modulesfinal
Python modulesfinal
 
The Ring programming language version 1.5.3 book - Part 61 of 184
The Ring programming language version 1.5.3 book - Part 61 of 184The Ring programming language version 1.5.3 book - Part 61 of 184
The Ring programming language version 1.5.3 book - Part 61 of 184
 
The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10
 
response of system for given transfer function
response of system for given transfer functionresponse of system for given transfer function
response of system for given transfer function
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 
The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.5.4 book - Part 52 of 185The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.5.4 book - Part 52 of 185
 
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий КуриловАсинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
 
Lập trình Python cơ bản
Lập trình Python cơ bảnLập trình Python cơ bản
Lập trình Python cơ bản
 
The secrets of inverse brogramming
The secrets of inverse brogrammingThe secrets of inverse brogramming
The secrets of inverse brogramming
 
Program Language - Fall 2013
Program Language - Fall 2013 Program Language - Fall 2013
Program Language - Fall 2013
 
Math 3-H6
Math 3-H6Math 3-H6
Math 3-H6
 
How fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practiceHow fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practice
 

Viewers also liked

2, 3 John & Jude
2, 3 John & Jude2, 3 John & Jude
2, 3 John & Jude
pegbaker
 
Repaso de conceptos de planilla de cálculos
Repaso de conceptos de planilla de cálculosRepaso de conceptos de planilla de cálculos
Repaso de conceptos de planilla de cálculosLauti Gomez
 
Guía teórica seguridad informatica
Guía teórica seguridad informaticaGuía teórica seguridad informatica
Guía teórica seguridad informaticaLauti Gomez
 
Preliminary task evaluation
Preliminary task evaluationPreliminary task evaluation
Preliminary task evaluationHannah Wallace
 
νεο Hydrobot teliko
νεο Hydrobot telikoνεο Hydrobot teliko
νεο Hydrobot teliko
MHTSOS2007
 

Viewers also liked (9)

B
BB
B
 
2, 3 John & Jude
2, 3 John & Jude2, 3 John & Jude
2, 3 John & Jude
 
Repaso de conceptos de planilla de cálculos
Repaso de conceptos de planilla de cálculosRepaso de conceptos de planilla de cálculos
Repaso de conceptos de planilla de cálculos
 
Guía teórica seguridad informatica
Guía teórica seguridad informaticaGuía teórica seguridad informatica
Guía teórica seguridad informatica
 
Contar
ContarContar
Contar
 
Preliminary task evaluation
Preliminary task evaluationPreliminary task evaluation
Preliminary task evaluation
 
νεο Hydrobot teliko
νεο Hydrobot telikoνεο Hydrobot teliko
νεο Hydrobot teliko
 
12 daniel defoe
12   daniel defoe12   daniel defoe
12 daniel defoe
 
Función si
Función siFunción si
Función si
 

Similar to R part II

01_introduction_lab.pdf
01_introduction_lab.pdf01_introduction_lab.pdf
01_introduction_lab.pdf
zehiwot hone
 
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Dr. Volkan OBAN
 
Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Cdiscount
 
r studio presentation.pptx
r studio presentation.pptxr studio presentation.pptx
r studio presentation.pptx
DevikaRaj14
 
r studio presentation.pptx
r studio presentation.pptxr studio presentation.pptx
r studio presentation.pptx
DevikaRaj14
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
Kevin Chun-Hsien Hsu
 
R programming language
R programming languageR programming language
R programming language
Alberto Minetti
 
Class 30: Sex, Religion, and Politics
Class 30: Sex, Religion, and PoliticsClass 30: Sex, Religion, and Politics
Class 30: Sex, Religion, and Politics
David Evans
 
6. Vectors – Data Frames
6. Vectors – Data Frames6. Vectors – Data Frames
6. Vectors – Data Frames
FAO
 
Elixir and OTP Apps introduction
Elixir and OTP Apps introductionElixir and OTP Apps introduction
Elixir and OTP Apps introduction
Gonzalo Gabriel Jiménez Fuentes
 
R part I
R part IR part I
R part I
Ruru Chowdhury
 
Welcome to python
Welcome to pythonWelcome to python
Welcome to python
Kyunghoon Kim
 
Table of Useful R commands.
Table of Useful R commands.Table of Useful R commands.
Table of Useful R commands.
Dr. Volkan OBAN
 
Basic practice of R
Basic practice of RBasic practice of R
Basic practice of R
Yoshiki Satotani
 
The Ring programming language version 1.3 book - Part 16 of 88
The Ring programming language version 1.3 book - Part 16 of 88The Ring programming language version 1.3 book - Part 16 of 88
The Ring programming language version 1.3 book - Part 16 of 88
Mahmoud Samir Fayed
 
Matlab 1
Matlab 1Matlab 1
Matlab 1asguna
 
Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School ProgrammersSiva Arunachalam
 

Similar to R part II (20)

01_introduction_lab.pdf
01_introduction_lab.pdf01_introduction_lab.pdf
01_introduction_lab.pdf
 
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
 
Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)
 
8th semester Computer Science and Information Science Engg (2013 December) Qu...
8th semester Computer Science and Information Science Engg (2013 December) Qu...8th semester Computer Science and Information Science Engg (2013 December) Qu...
8th semester Computer Science and Information Science Engg (2013 December) Qu...
 
r studio presentation.pptx
r studio presentation.pptxr studio presentation.pptx
r studio presentation.pptx
 
r studio presentation.pptx
r studio presentation.pptxr studio presentation.pptx
r studio presentation.pptx
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
 
R programming language
R programming languageR programming language
R programming language
 
Class 30: Sex, Religion, and Politics
Class 30: Sex, Religion, and PoliticsClass 30: Sex, Religion, and Politics
Class 30: Sex, Religion, and Politics
 
6. Vectors – Data Frames
6. Vectors – Data Frames6. Vectors – Data Frames
6. Vectors – Data Frames
 
Elixir and OTP Apps introduction
Elixir and OTP Apps introductionElixir and OTP Apps introduction
Elixir and OTP Apps introduction
 
Learn Matlab
Learn MatlabLearn Matlab
Learn Matlab
 
R part I
R part IR part I
R part I
 
Welcome to python
Welcome to pythonWelcome to python
Welcome to python
 
Table of Useful R commands.
Table of Useful R commands.Table of Useful R commands.
Table of Useful R commands.
 
presentazione
presentazionepresentazione
presentazione
 
Basic practice of R
Basic practice of RBasic practice of R
Basic practice of R
 
The Ring programming language version 1.3 book - Part 16 of 88
The Ring programming language version 1.3 book - Part 16 of 88The Ring programming language version 1.3 book - Part 16 of 88
The Ring programming language version 1.3 book - Part 16 of 88
 
Matlab 1
Matlab 1Matlab 1
Matlab 1
 
Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School Programmers
 

More from Ruru Chowdhury

The One With The Wizards and Dragons. Prelims
The One With The Wizards and Dragons. PrelimsThe One With The Wizards and Dragons. Prelims
The One With The Wizards and Dragons. Prelims
Ruru Chowdhury
 
The One With The Wizards and Dragons. Finals
The One With The Wizards and Dragons. FinalsThe One With The Wizards and Dragons. Finals
The One With The Wizards and Dragons. Finals
Ruru Chowdhury
 
Statr session 25 and 26
Statr session 25 and 26Statr session 25 and 26
Statr session 25 and 26
Ruru Chowdhury
 
Statr session 23 and 24
Statr session 23 and 24Statr session 23 and 24
Statr session 23 and 24
Ruru Chowdhury
 
Statr session 21 and 22
Statr session 21 and 22Statr session 21 and 22
Statr session 21 and 22
Ruru Chowdhury
 
Statr session 19 and 20
Statr session 19 and 20Statr session 19 and 20
Statr session 19 and 20
Ruru Chowdhury
 
Statr session 17 and 18
Statr session 17 and 18Statr session 17 and 18
Statr session 17 and 18
Ruru Chowdhury
 
Statr session 17 and 18 (ASTR)
Statr session 17 and 18 (ASTR)Statr session 17 and 18 (ASTR)
Statr session 17 and 18 (ASTR)
Ruru Chowdhury
 
Statr session 15 and 16
Statr session 15 and 16Statr session 15 and 16
Statr session 15 and 16
Ruru Chowdhury
 
Statr session14, Jan 11
Statr session14, Jan 11Statr session14, Jan 11
Statr session14, Jan 11
Ruru Chowdhury
 
JM Statr session 13, Jan 11
JM Statr session 13, Jan 11JM Statr session 13, Jan 11
JM Statr session 13, Jan 11
Ruru Chowdhury
 
Statr sessions 11 to 12
Statr sessions 11 to 12Statr sessions 11 to 12
Statr sessions 11 to 12
Ruru Chowdhury
 
Nosql part3
Nosql part3Nosql part3
Nosql part3
Ruru Chowdhury
 
Nosql part1 8th December
Nosql part1 8th December Nosql part1 8th December
Nosql part1 8th December
Ruru Chowdhury
 
Nosql part 2
Nosql part 2Nosql part 2
Nosql part 2
Ruru Chowdhury
 
Statr sessions 9 to 10
Statr sessions 9 to 10Statr sessions 9 to 10
Statr sessions 9 to 10
Ruru Chowdhury
 
R part iii
R part iiiR part iii
R part iii
Ruru Chowdhury
 
Statr sessions 7 to 8
Statr sessions 7 to 8Statr sessions 7 to 8
Statr sessions 7 to 8
Ruru Chowdhury
 
Statr sessions 4 to 6
Statr sessions 4 to 6Statr sessions 4 to 6
Statr sessions 4 to 6
Ruru Chowdhury
 
Statistics with R
Statistics with R Statistics with R
Statistics with R
Ruru Chowdhury
 

More from Ruru Chowdhury (20)

The One With The Wizards and Dragons. Prelims
The One With The Wizards and Dragons. PrelimsThe One With The Wizards and Dragons. Prelims
The One With The Wizards and Dragons. Prelims
 
The One With The Wizards and Dragons. Finals
The One With The Wizards and Dragons. FinalsThe One With The Wizards and Dragons. Finals
The One With The Wizards and Dragons. Finals
 
Statr session 25 and 26
Statr session 25 and 26Statr session 25 and 26
Statr session 25 and 26
 
Statr session 23 and 24
Statr session 23 and 24Statr session 23 and 24
Statr session 23 and 24
 
Statr session 21 and 22
Statr session 21 and 22Statr session 21 and 22
Statr session 21 and 22
 
Statr session 19 and 20
Statr session 19 and 20Statr session 19 and 20
Statr session 19 and 20
 
Statr session 17 and 18
Statr session 17 and 18Statr session 17 and 18
Statr session 17 and 18
 
Statr session 17 and 18 (ASTR)
Statr session 17 and 18 (ASTR)Statr session 17 and 18 (ASTR)
Statr session 17 and 18 (ASTR)
 
Statr session 15 and 16
Statr session 15 and 16Statr session 15 and 16
Statr session 15 and 16
 
Statr session14, Jan 11
Statr session14, Jan 11Statr session14, Jan 11
Statr session14, Jan 11
 
JM Statr session 13, Jan 11
JM Statr session 13, Jan 11JM Statr session 13, Jan 11
JM Statr session 13, Jan 11
 
Statr sessions 11 to 12
Statr sessions 11 to 12Statr sessions 11 to 12
Statr sessions 11 to 12
 
Nosql part3
Nosql part3Nosql part3
Nosql part3
 
Nosql part1 8th December
Nosql part1 8th December Nosql part1 8th December
Nosql part1 8th December
 
Nosql part 2
Nosql part 2Nosql part 2
Nosql part 2
 
Statr sessions 9 to 10
Statr sessions 9 to 10Statr sessions 9 to 10
Statr sessions 9 to 10
 
R part iii
R part iiiR part iii
R part iii
 
Statr sessions 7 to 8
Statr sessions 7 to 8Statr sessions 7 to 8
Statr sessions 7 to 8
 
Statr sessions 4 to 6
Statr sessions 4 to 6Statr sessions 4 to 6
Statr sessions 4 to 6
 
Statistics with R
Statistics with R Statistics with R
Statistics with R
 

Recently uploaded

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 

Recently uploaded (20)

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 

R part II

  • 1. Vector with regularly spaced numbers > 1:10 [1] 1 2 3 > seq(1,10) [1] 1 2 3 > seq(1,10,2) [1] 1 3 5 7 9 4 5 6 7 8 9 10 4 5 6 7 8 9 10 • We have used both “:” operator and seq command • Note the last command where we have used “2” as step, which is the “by” argument of the seq command
  • 2. Try some sequence or seq commands …. > seq(0,1, length=11) [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 > seq(4,10,by=0.5) [1] 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 > seq(4,10,0.5) [1] 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 8.5 9.0 9.5 10.0 > seq(2,8,0.3) [1] 2.0 2.3 2.6 2.9 3.2 3.5 3.8 4.1 4.4 4.7 5.0 5.3 5.6 5.9 6.2 6.5 6.8 7.1 7.4 7.7 [21] 8.0 > seq.int(2,8,0.3) [1] 2.0 2.3 2.6 2.9 3.2 3.5 3.8 4.1 4.4 4.7 5.0 5.3 5.6 5.9 6.2 6.5 6.8 7.1 7.4 7.7 [21] 8.0 > seq(2,8,length.out=10) [1] 2.000000 2.666667 3.333333 4.000000 4.666667 5.333333 6.000000 6.666667 7.333333 [10] 8.000000
  • 3. Try more seq commands …. > seq(1,5,0.3) [1] 1.0 1.3 1.6 1.9 2.2 2.5 2.8 3.1 3.4 3.7 4.0 4.3 4.6 4.9 > pi:6 [1] 3.141593 4.141593 5.141593 > 6:pi [1] 6 5 4 > 10:-2 [1] 10 9 8 7 6 5 4 3 2 1 0 -1 -2 > -7:8 [1] -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 • You can generate decreasing sequence • Try generating a sequence of negative numbers
  • 4. Think and try …... Generate a sequence of the following numbers: 0.0 0.2 0.4 0.6 0.8 1.0 1.0 2.0 3.0 6.0 7.0 8.0 9.0 10.0 100.0 4.0 Hints • You have to use more than one sequence. • But how will you include “100”? 5.0
  • 5. Think and try ….. Possible Solution Generate a sequence of the following numbers: 0.0 0.2 0.4 0.6 0.8 1.0 1.0 2.0 3.0 6.0 7.0 8.0 9.0 10.0 100.0 > seq(0, 1, length=6) [1] 0.0 0.2 0.4 0.6 0.8 1.0 > seq.1<-seq(0, 1, length=6) > c(seq.1,1:10,100) [1] 0.0 0.2 0.4 0.6 [14] 8.0 9.0 10.0 100.0 0.8 1.0 1.0 2.0 3.0 4.0 4.0 5.0 5.0 6.0 7.0
  • 6. Try replicate or rep command > rep(1:5,2) [1] 1 2 3 4 5 1 2 3 4 5 > rep(1:5, length=12) [1] 1 2 3 4 5 1 2 3 4 5 1 2 > rep(c('one', 'two'), c(6, 3)) [1] "one" "one" "one" "one" "one" "one" "two" "two" "two" Now enter help(rep) command and try the examples
  • 7. Try replicate or rep command > rep(1:4, each = 2) [1] 1 1 2 2 3 3 4 4 > rep(1:4, c(2,2,2,2)) [1] 1 1 2 2 3 3 4 4 > rep(5:8, c(2,1,2,1)) [1] 5 5 6 7 7 8 > rep(1:4, each = 2, len = 4) [1] 1 1 2 2 Hope you are enjoying as we go….. Have you noted the arguments “each” and “len”gth? Now note the “times” argument > rep(1:4, each = 2, times = 3) [1] 1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4
  • 8. Try Histogram…. Suppose the top 25 ranked movies made the following gross receipts for a Week: 29.6 28.2 19.6 13.7 13.0 7.8 3.4 2.0 1.9 1.0 0.7 0.4 0.4 0.3 0.3 0.3 0.3 0.3 0.2 0.2 0.2 0.1 0.1 0.1 0.1 0.1 Scan the data and then draw some histograms. > x [1] 29.6 28.2 19.6 13.7 13.0 0.4 0.4 0.3 0.3 0.3 [17] 0.3 0.3 0.2 0.2 0.2 > receipts<-x > hist(receipts) 7.8 3.4 2.0 1.9 1.0 0.1 0.1 0.1 0.1 0.1 0.7
  • 9. Try Histogram…. Suppose the top 25 ranked movies made the following gross receipts for a Week: 29.6 28.2 19.6 13.7 13.0 7.8 3.4 2.0 1.9 1.0 0.7 0.4 0.4 0.3 0.3 0.3 0.3 0.3 0.2 0.2 0.2 0.1 0.1 0.1 0.1 0.1
  • 10. Now try better histograms …. Add colour, change colour, add title for the histogram, add title for x-axis and then y-axis > hist(receipts, col="red2") > hist(receipts, col="red4") > hist(receipts, col="red2",main="Gross Receipts for first 25 ranked movies") > hist(receipts, col="red2",main="Gross Receipts for first 25 ranked movies",xlab="receipts in a week") > hist(receipts, col="red2",main="Gross Receipts for first 25 ranked movies",xlab="receipts in a week",ylab="count of movies")
  • 11. Now try better histograms …. Your new histogram should look like this
  • 12. Now try better histograms …. Now put the range for x-axis and y-axis > hist(receipts, col="red2",main="Gross Receipts for first 25 ranked movies",xlab="receipts in a week",ylab="count of movies",xlim=c(0.1,35),ylim=c(0,25))
  • 13. Now more about histograms …. Now try breaks=…. What is “breaks”? > hist(receipts,breaks=3,col="red2",main="Gross Receipts for first 25 ranked movies",xlab="receipts in a week",ylab="count of movies") Remember: Breaks is just a suggestion to R
  • 14. Now more about breaks …. “breaks” can also specify the actual break points in a histogram > hist(receipts,breaks=c(0,1,2,3,4,5,10,20,max(x)),col="violetred") Note the break points
  • 15. Summary and Fivenum Suppose, CEO yearly compensations are sampled and the following are found (in millions). 12 0.4 5 2 50 8 3 1 4 0.25 > sals [1] 12.00 0.40 5.00 2.00 50.00 8.00 3.00 1.00 4.00 0.25 > mean(sals) # the average [1] 8.565 > var(sals) # the variance [1] 225.5145 > sd(sals) # the standard deviation [1] 15.01714 > median(sals) # the median [1] 3.5 > summary(sals) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.250 1.250 3.500 8.565 7.250 50.000 > fivenum(sals) # min, lower hinge, Median, upper hinge, max [1] 0.25 1.00 3.50 8.00 50.00 > quantile(sals) 0% 25% 50% 75% 100% 0.25 1.25 3.50 7.25 50.00
  • 17. Difference between Fivenum and Quantile: Lower and Upper Hinge The sorted data: 0.25 0.4 1 2 3 3.5 4 5 8 12 50 Median = 3.5 • The lower hinge is the median of all the data to the left of the median (3.5), not counting this particular data point (if it is one.) • The upper hinge is similarly defined.