SlideShare a Scribd company logo
Time series in R
Time Series in R is used to see how an object behaves
over a period of time. In R, it can be easily done
by ts() function with some parameters.
Time series takes the data vector and each data is
connected with timestamp value as given by the user.
This function is mostly used to learn and forecast the
behavior of an asset in business for a period of time.
For example, sales analysis of a company, inventory
analysis, price analysis of a particular stock or market,
population analysis, etc.
• Syntax: objectName <- ts(data, start, end, frequency)
• where,
• data represents the data vector
• start represents the first observation in time series
• end represents the last observation in time series
• frequency represents number of observations per unit
time. For example, frequency=1 for monthly data.
• x <- c(580, 7813, 28266, 59287, 75700,
• 87820, 95314, 126214, 218843, 471497,
• 936851, 1508725, 2072113)
•
• # library required for decimal_date() function
• library(lubridate)
•
• # output to be created as png file
• png(file ="timeSeries.png")
•
• # creating time series object
• # from date 22 January, 2020
• mts <- ts(x, start = decimal_date(ymd("2020-01-22")), frequency = 365.25 / 7)
•
• # plotting the graph
• plot(mts, xlab ="Weekly Data",
• ylab ="Total Positive Cases",
• main ="COVID-19 Pandemic",
• col.main ="darkgreen")
•
• # saving the file
• dev.off()
•
Multivariate Time Series
• Multivariate Time Series is creating multiple time series in a single
chart.
• Example: Taking data of total positive cases and total deaths from
COVID-19 weekly from 22 January 2020 to 15 April 2020 in data vector.
• # Weekly data of COVID-19 positive cases and
• # weekly deaths from 22 January, 2020 to
• # 15 April, 2020
• positiveCases <- c(580, 7813, 28266, 59287,
• 75700, 87820, 95314, 126214,
• 218843, 471497, 936851,
• 1508725, 2072113)
•
• deaths <- c(17, 270, 565, 1261, 2126, 2800,
• 3285, 4628, 8951, 21283, 47210,
• 88480, 138475)
• # library required for decimal_date() function
• library(lubridate)
•
• # output to be created as png file
• png(file ="multivariateTimeSeries.png")
•
• # creating multivariate time series object
• # from date 22 January, 2020
• mts <- ts(cbind(positiveCases, deaths),
• start = decimal_date(ymd("2020-01-22")),
• frequency = 365.25 / 7) (column Bind to merge two data frames)
•
• # plotting the graph
• plot(mts, xlab ="Weekly Data",
• main ="COVID-19 Cases",
• col.main ="darkgreen")
•
• # saving the file
• dev.off()
Data Visualization in R
• Data visualization is the technique used to deliver
insights in data using visual cues such as graphs,
charts, maps, and many others.
• This is useful as it helps in intuitive and easy
understanding of the large quantities of data and
thereby make better decisions regarding it.
• R is a language that is designed for statistical
computing, graphical data analysis, and scientific
research.
• It is usually preferred for data visualization as it offers
flexibility and minimum required coding through its
packages.
Types of Data Visualizations
• Some of the various types of visualizations offered by R
are:
• Bar Plot
• There are two types of bar plots- horizontal and
vertical which represent data points as horizontal or
vertical bars of certain lengths proportional to the
value of the data item. They are generally used for
continuous and categorical variable plotting. By setting
the horiz parameter to true and false, we can get
horizontal and vertical bar plots respectively.
•
• barplot(airquality$Ozone,
• main = 'Ozone Concenteration in air',
• xlab = 'ozone levels', horiz = TRUE)
• Or
• barplot(airquality$Ozone, main = 'Ozone Concenteration
in air', xlab = 'ozone levels', col ='blue', horiz = FALSE)
• Bar plots are used for the following scenarios:
• To perform a comparative study between the various
data categories in the data set.
• To analyze the change of a variable over time in months
or years.
•
Histogram
• A histogram is like a bar chart as it uses bars of
varying height to represent data distribution.
However, in a histogram values are grouped
into consecutive intervals called bins. In a
Histogram, continuous values are grouped and
displayed in these bins whose size can be
varied.
Example:
•
• data(airquality)
•
• hist(airquality$Temp, main ="La Guardia Airport's
• Maximum Temperature(Daily)",
• xlab ="Temperature(Fahrenheit)",
• xlim = c(50, 125), col ="yellow",
• freq = TRUE)
• Histograms are used in the following scenarios:
• To verify an equal and symmetric distribution of the data.
• To identify deviations from expected values.
•
Box Plot
• The statistical summary of the given data is presented
graphically using a boxplot. A boxplot depicts information like
the minimum and maximum data point, the median value, first
and third quartile, and interquartile range.
• data(airquality)
•
• boxplot(airquality$Wind, main = "Average wind speed
• at La Guardia Airport",
• xlab = "Miles per hour", ylab = "Wind",
• col = "orange", border = "brown",
• horizontal = TRUE, notch = TRUE)
• Box Plots are used for:
• To give a comprehensive statistical description of the data
through a visual cue.
• To identify the outlier points that do not lie in the inter-quartile
range of data.
Scatter Plot
• A scatter plot is composed of many points on a Cartesian
plane. Each point denotes the value taken by two parameters
and helps us easily identify the relationship between them.
•
• data(airquality)
•
• plot(airquality$Ozone, airquality$Month,
• main ="Scatterplot Example",
• xlab ="Ozone Concentration in parts per billion",
• ylab =" Month of observation ", pch = 19)
•
• Scatter Plots are used in the following scenarios:
• To show whether an association exists between bivariate data.
• To measure the strength and direction of such a relationship.
Heat Map
• Heatmap is defined as a graphical representation of data using
colors to visualize the value of the matrix. heatmap() function
is used to plot heatmap.
• Syntax: heatmap(data)
• Parameters: data: It represent matrix data, such as values of
rows and columns
• Return: This function draws a heatmap.
•
• data <- matrix(rnorm(50, 0, 5), nrow = 5, ncol = 5)
•
• # Column names
• colnames(data) <- paste0("col", 1:5)
• rownames(data) <- paste0("row", 1:5)
•
• # Draw a heatmap
• heatmap(data)
Scan()
• Reading time series of data can be in two
types
• Scan() and ts()
• The scan function reads data into a vector or
list from a file or the R console.
• data <- data.frame(x1 = c(4, 4, 1, 9),
data.frame x2 = c(1, 8, 4, 0), x3 = c(5, 3, 5, 6))
• write.table(data file = "data.txt", row.names =
FALSE)
TS()
• This function can be used to store time series
data and creates the time series object.
• Ts(data, start,end, frequency) are the
parameters.
Plotting time series data
• Often you may want to plot a time series in R
to visualize how the values of the time series
are changing over time.
• Suppose we have the following dataset in R:

More Related Content

What's hot

Oracle python pandas merge DataFrames
Oracle python pandas merge DataFramesOracle python pandas merge DataFrames
Oracle python pandas merge DataFrames
Johan Louwers
 
Data Analysis and Programming in R
Data Analysis and Programming in RData Analysis and Programming in R
Data Analysis and Programming in REshwar Sai
 
Data manipulation on r
Data manipulation on rData manipulation on r
Data manipulation on r
Abhik Seal
 
Seaborn.pptx
Seaborn.pptxSeaborn.pptx
Seaborn.pptx
TheMusicFever
 
DPLYR package in R
DPLYR package in RDPLYR package in R
DPLYR package in R
Bimba Pawar
 
Association rules
Association rulesAssociation rules
Association rules
Dr. C.V. Suresh Babu
 
Discrete Mathematics - Mathematics For Computer Science
Discrete Mathematics -  Mathematics For Computer ScienceDiscrete Mathematics -  Mathematics For Computer Science
Discrete Mathematics - Mathematics For Computer Science
Ram Sagar Mourya
 
4. R- files Reading and Writing
4. R- files Reading and Writing4. R- files Reading and Writing
4. R- files Reading and Writing
krishna singh
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
Piyush rai
 
Data manipulation with dplyr
Data manipulation with dplyrData manipulation with dplyr
Data manipulation with dplyr
Romain Francois
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization Python Seaborn Data Visualization
Python Seaborn Data Visualization
Sourabh Sahu
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2chidabdu
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Gopi Saiteja
 
NUMPY-2.pptx
NUMPY-2.pptxNUMPY-2.pptx
NUMPY-2.pptx
MahendraVusa
 
dplyr Package in R
dplyr Package in Rdplyr Package in R
dplyr Package in R
Vedant Shah
 
3. R- list and data frame
3. R- list and data frame3. R- list and data frame
3. R- list and data frame
krishna singh
 
Relations
RelationsRelations
Relations
Ali Saleem
 
Introduction to ggplot2
Introduction to ggplot2Introduction to ggplot2
Introduction to ggplot2maikroeder
 
Data visualization with R
Data visualization with RData visualization with R
Data visualization with R
Biswajeet Dasmajumdar
 
Python : Data Types
Python : Data TypesPython : Data Types

What's hot (20)

Oracle python pandas merge DataFrames
Oracle python pandas merge DataFramesOracle python pandas merge DataFrames
Oracle python pandas merge DataFrames
 
Data Analysis and Programming in R
Data Analysis and Programming in RData Analysis and Programming in R
Data Analysis and Programming in R
 
Data manipulation on r
Data manipulation on rData manipulation on r
Data manipulation on r
 
Seaborn.pptx
Seaborn.pptxSeaborn.pptx
Seaborn.pptx
 
DPLYR package in R
DPLYR package in RDPLYR package in R
DPLYR package in R
 
Association rules
Association rulesAssociation rules
Association rules
 
Discrete Mathematics - Mathematics For Computer Science
Discrete Mathematics -  Mathematics For Computer ScienceDiscrete Mathematics -  Mathematics For Computer Science
Discrete Mathematics - Mathematics For Computer Science
 
4. R- files Reading and Writing
4. R- files Reading and Writing4. R- files Reading and Writing
4. R- files Reading and Writing
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
 
Data manipulation with dplyr
Data manipulation with dplyrData manipulation with dplyr
Data manipulation with dplyr
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization Python Seaborn Data Visualization
Python Seaborn Data Visualization
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
NUMPY-2.pptx
NUMPY-2.pptxNUMPY-2.pptx
NUMPY-2.pptx
 
dplyr Package in R
dplyr Package in Rdplyr Package in R
dplyr Package in R
 
3. R- list and data frame
3. R- list and data frame3. R- list and data frame
3. R- list and data frame
 
Relations
RelationsRelations
Relations
 
Introduction to ggplot2
Introduction to ggplot2Introduction to ggplot2
Introduction to ggplot2
 
Data visualization with R
Data visualization with RData visualization with R
Data visualization with R
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 

Similar to Time Series.pptx

Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
Tahera Shaikh
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
AmanBhalla14
 
R training3
R training3R training3
R training3
Hellen Gakuruh
 
Unit 5 Time series Data Analysis.pdf
Unit 5 Time series Data Analysis.pdfUnit 5 Time series Data Analysis.pdf
Unit 5 Time series Data Analysis.pdf
Sheba41
 
lecture1.ppt
lecture1.pptlecture1.ppt
lecture1.ppt
SagarDR5
 
C++ Notes PPT.ppt
C++ Notes PPT.pptC++ Notes PPT.ppt
C++ Notes PPT.ppt
Alpha474815
 
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkTUOS-Sam
 
Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docx
helzerpatrina
 
R language introduction
R language introductionR language introduction
R language introduction
Shashwat Shriparv
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in R
Ilya Zhbannikov
 
R training5
R training5R training5
R training5
Hellen Gakuruh
 
Practical data science_public
Practical data science_publicPractical data science_public
Practical data science_public
Long Nguyen
 
R training2
R training2R training2
R training2
Hellen Gakuruh
 
Chapter3_Visualizations2.pdf
Chapter3_Visualizations2.pdfChapter3_Visualizations2.pdf
Chapter3_Visualizations2.pdf
MekiyaShigute1
 
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Yao Yao
 
Module 1 notes of data warehousing and data
Module 1 notes of data warehousing and dataModule 1 notes of data warehousing and data
Module 1 notes of data warehousing and data
vijipersonal2012
 
R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011
Mandi Walls
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
Khulna University
 
7 QC - NEW.ppt
7 QC - NEW.ppt7 QC - NEW.ppt
7 QC - NEW.ppt
AmitGajbhiye9
 
Cardinality Estimation through Histogram in Apache Spark 2.3 with Ron Hu and ...
Cardinality Estimation through Histogram in Apache Spark 2.3 with Ron Hu and ...Cardinality Estimation through Histogram in Apache Spark 2.3 with Ron Hu and ...
Cardinality Estimation through Histogram in Apache Spark 2.3 with Ron Hu and ...
Databricks
 

Similar to Time Series.pptx (20)

Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
 
R training3
R training3R training3
R training3
 
Unit 5 Time series Data Analysis.pdf
Unit 5 Time series Data Analysis.pdfUnit 5 Time series Data Analysis.pdf
Unit 5 Time series Data Analysis.pdf
 
lecture1.ppt
lecture1.pptlecture1.ppt
lecture1.ppt
 
C++ Notes PPT.ppt
C++ Notes PPT.pptC++ Notes PPT.ppt
C++ Notes PPT.ppt
 
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & Coursework
 
Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docx
 
R language introduction
R language introductionR language introduction
R language introduction
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in R
 
R training5
R training5R training5
R training5
 
Practical data science_public
Practical data science_publicPractical data science_public
Practical data science_public
 
R training2
R training2R training2
R training2
 
Chapter3_Visualizations2.pdf
Chapter3_Visualizations2.pdfChapter3_Visualizations2.pdf
Chapter3_Visualizations2.pdf
 
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
 
Module 1 notes of data warehousing and data
Module 1 notes of data warehousing and dataModule 1 notes of data warehousing and data
Module 1 notes of data warehousing and data
 
R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
7 QC - NEW.ppt
7 QC - NEW.ppt7 QC - NEW.ppt
7 QC - NEW.ppt
 
Cardinality Estimation through Histogram in Apache Spark 2.3 with Ron Hu and ...
Cardinality Estimation through Histogram in Apache Spark 2.3 with Ron Hu and ...Cardinality Estimation through Histogram in Apache Spark 2.3 with Ron Hu and ...
Cardinality Estimation through Histogram in Apache Spark 2.3 with Ron Hu and ...
 

More from Ramakrishna Reddy Bijjam

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
Ramakrishna Reddy Bijjam
 
Arrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptxArrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptx
Ramakrishna Reddy Bijjam
 
Auxiliary, Cache and Virtual memory.pptx
Auxiliary, Cache and Virtual memory.pptxAuxiliary, Cache and Virtual memory.pptx
Auxiliary, Cache and Virtual memory.pptx
Ramakrishna Reddy Bijjam
 
Python With MongoDB in advanced Python.pptx
Python With MongoDB in advanced Python.pptxPython With MongoDB in advanced Python.pptx
Python With MongoDB in advanced Python.pptx
Ramakrishna Reddy Bijjam
 
Pointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptxPointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptx
Ramakrishna Reddy Bijjam
 
Certinity Factor and Dempster-shafer theory .pptx
Certinity Factor and Dempster-shafer theory .pptxCertinity Factor and Dempster-shafer theory .pptx
Certinity Factor and Dempster-shafer theory .pptx
Ramakrishna Reddy Bijjam
 
Auxiliary Memory in computer Architecture.pptx
Auxiliary Memory in computer Architecture.pptxAuxiliary Memory in computer Architecture.pptx
Auxiliary Memory in computer Architecture.pptx
Ramakrishna Reddy Bijjam
 
Random Forest Decision Tree.pptx
Random Forest Decision Tree.pptxRandom Forest Decision Tree.pptx
Random Forest Decision Tree.pptx
Ramakrishna Reddy Bijjam
 
K Means Clustering in ML.pptx
K Means Clustering in ML.pptxK Means Clustering in ML.pptx
K Means Clustering in ML.pptx
Ramakrishna Reddy Bijjam
 
Pandas.pptx
Pandas.pptxPandas.pptx
Python With MongoDB.pptx
Python With MongoDB.pptxPython With MongoDB.pptx
Python With MongoDB.pptx
Ramakrishna Reddy Bijjam
 
Python with MySql.pptx
Python with MySql.pptxPython with MySql.pptx
Python with MySql.pptx
Ramakrishna Reddy Bijjam
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdfPYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
Ramakrishna Reddy Bijjam
 
BInary file Operations.pptx
BInary file Operations.pptxBInary file Operations.pptx
BInary file Operations.pptx
Ramakrishna Reddy Bijjam
 
Data Science in Python.pptx
Data Science in Python.pptxData Science in Python.pptx
Data Science in Python.pptx
Ramakrishna Reddy Bijjam
 
CSV JSON and XML files in Python.pptx
CSV JSON and XML files in Python.pptxCSV JSON and XML files in Python.pptx
CSV JSON and XML files in Python.pptx
Ramakrishna Reddy Bijjam
 
HTML files in python.pptx
HTML files in python.pptxHTML files in python.pptx
HTML files in python.pptx
Ramakrishna Reddy Bijjam
 
Regular Expressions in Python.pptx
Regular Expressions in Python.pptxRegular Expressions in Python.pptx
Regular Expressions in Python.pptx
Ramakrishna Reddy Bijjam
 
datareprersentation 1.pptx
datareprersentation 1.pptxdatareprersentation 1.pptx
datareprersentation 1.pptx
Ramakrishna Reddy Bijjam
 
Apriori.pptx
Apriori.pptxApriori.pptx

More from Ramakrishna Reddy Bijjam (20)

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Arrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptxArrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptx
 
Auxiliary, Cache and Virtual memory.pptx
Auxiliary, Cache and Virtual memory.pptxAuxiliary, Cache and Virtual memory.pptx
Auxiliary, Cache and Virtual memory.pptx
 
Python With MongoDB in advanced Python.pptx
Python With MongoDB in advanced Python.pptxPython With MongoDB in advanced Python.pptx
Python With MongoDB in advanced Python.pptx
 
Pointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptxPointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptx
 
Certinity Factor and Dempster-shafer theory .pptx
Certinity Factor and Dempster-shafer theory .pptxCertinity Factor and Dempster-shafer theory .pptx
Certinity Factor and Dempster-shafer theory .pptx
 
Auxiliary Memory in computer Architecture.pptx
Auxiliary Memory in computer Architecture.pptxAuxiliary Memory in computer Architecture.pptx
Auxiliary Memory in computer Architecture.pptx
 
Random Forest Decision Tree.pptx
Random Forest Decision Tree.pptxRandom Forest Decision Tree.pptx
Random Forest Decision Tree.pptx
 
K Means Clustering in ML.pptx
K Means Clustering in ML.pptxK Means Clustering in ML.pptx
K Means Clustering in ML.pptx
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
 
Python With MongoDB.pptx
Python With MongoDB.pptxPython With MongoDB.pptx
Python With MongoDB.pptx
 
Python with MySql.pptx
Python with MySql.pptxPython with MySql.pptx
Python with MySql.pptx
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdfPYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
 
BInary file Operations.pptx
BInary file Operations.pptxBInary file Operations.pptx
BInary file Operations.pptx
 
Data Science in Python.pptx
Data Science in Python.pptxData Science in Python.pptx
Data Science in Python.pptx
 
CSV JSON and XML files in Python.pptx
CSV JSON and XML files in Python.pptxCSV JSON and XML files in Python.pptx
CSV JSON and XML files in Python.pptx
 
HTML files in python.pptx
HTML files in python.pptxHTML files in python.pptx
HTML files in python.pptx
 
Regular Expressions in Python.pptx
Regular Expressions in Python.pptxRegular Expressions in Python.pptx
Regular Expressions in Python.pptx
 
datareprersentation 1.pptx
datareprersentation 1.pptxdatareprersentation 1.pptx
datareprersentation 1.pptx
 
Apriori.pptx
Apriori.pptxApriori.pptx
Apriori.pptx
 

Recently uploaded

一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
Tiktokethiodaily
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
MaleehaSheikh2
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
ewymefz
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
StarCompliance.io
 
Business update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMIBusiness update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMI
AlejandraGmez176757
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Boston Institute of Analytics
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
correoyaya
 

Recently uploaded (20)

一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
 
Business update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMIBusiness update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMI
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
 

Time Series.pptx

  • 1. Time series in R Time Series in R is used to see how an object behaves over a period of time. In R, it can be easily done by ts() function with some parameters. Time series takes the data vector and each data is connected with timestamp value as given by the user. This function is mostly used to learn and forecast the behavior of an asset in business for a period of time. For example, sales analysis of a company, inventory analysis, price analysis of a particular stock or market, population analysis, etc.
  • 2. • Syntax: objectName <- ts(data, start, end, frequency) • where, • data represents the data vector • start represents the first observation in time series • end represents the last observation in time series • frequency represents number of observations per unit time. For example, frequency=1 for monthly data.
  • 3. • x <- c(580, 7813, 28266, 59287, 75700, • 87820, 95314, 126214, 218843, 471497, • 936851, 1508725, 2072113) • • # library required for decimal_date() function • library(lubridate) • • # output to be created as png file • png(file ="timeSeries.png") • • # creating time series object • # from date 22 January, 2020 • mts <- ts(x, start = decimal_date(ymd("2020-01-22")), frequency = 365.25 / 7) • • # plotting the graph • plot(mts, xlab ="Weekly Data", • ylab ="Total Positive Cases", • main ="COVID-19 Pandemic", • col.main ="darkgreen") • • # saving the file • dev.off() •
  • 4. Multivariate Time Series • Multivariate Time Series is creating multiple time series in a single chart. • Example: Taking data of total positive cases and total deaths from COVID-19 weekly from 22 January 2020 to 15 April 2020 in data vector. • # Weekly data of COVID-19 positive cases and • # weekly deaths from 22 January, 2020 to • # 15 April, 2020 • positiveCases <- c(580, 7813, 28266, 59287, • 75700, 87820, 95314, 126214, • 218843, 471497, 936851, • 1508725, 2072113) • • deaths <- c(17, 270, 565, 1261, 2126, 2800, • 3285, 4628, 8951, 21283, 47210, • 88480, 138475)
  • 5. • # library required for decimal_date() function • library(lubridate) • • # output to be created as png file • png(file ="multivariateTimeSeries.png") • • # creating multivariate time series object • # from date 22 January, 2020 • mts <- ts(cbind(positiveCases, deaths), • start = decimal_date(ymd("2020-01-22")), • frequency = 365.25 / 7) (column Bind to merge two data frames) • • # plotting the graph • plot(mts, xlab ="Weekly Data", • main ="COVID-19 Cases", • col.main ="darkgreen") • • # saving the file • dev.off()
  • 6. Data Visualization in R • Data visualization is the technique used to deliver insights in data using visual cues such as graphs, charts, maps, and many others. • This is useful as it helps in intuitive and easy understanding of the large quantities of data and thereby make better decisions regarding it. • R is a language that is designed for statistical computing, graphical data analysis, and scientific research. • It is usually preferred for data visualization as it offers flexibility and minimum required coding through its packages.
  • 7. Types of Data Visualizations • Some of the various types of visualizations offered by R are: • Bar Plot • There are two types of bar plots- horizontal and vertical which represent data points as horizontal or vertical bars of certain lengths proportional to the value of the data item. They are generally used for continuous and categorical variable plotting. By setting the horiz parameter to true and false, we can get horizontal and vertical bar plots respectively. •
  • 8. • barplot(airquality$Ozone, • main = 'Ozone Concenteration in air', • xlab = 'ozone levels', horiz = TRUE) • Or • barplot(airquality$Ozone, main = 'Ozone Concenteration in air', xlab = 'ozone levels', col ='blue', horiz = FALSE) • Bar plots are used for the following scenarios: • To perform a comparative study between the various data categories in the data set. • To analyze the change of a variable over time in months or years. •
  • 9. Histogram • A histogram is like a bar chart as it uses bars of varying height to represent data distribution. However, in a histogram values are grouped into consecutive intervals called bins. In a Histogram, continuous values are grouped and displayed in these bins whose size can be varied.
  • 10. Example: • • data(airquality) • • hist(airquality$Temp, main ="La Guardia Airport's • Maximum Temperature(Daily)", • xlab ="Temperature(Fahrenheit)", • xlim = c(50, 125), col ="yellow", • freq = TRUE) • Histograms are used in the following scenarios: • To verify an equal and symmetric distribution of the data. • To identify deviations from expected values. •
  • 11. Box Plot • The statistical summary of the given data is presented graphically using a boxplot. A boxplot depicts information like the minimum and maximum data point, the median value, first and third quartile, and interquartile range. • data(airquality) • • boxplot(airquality$Wind, main = "Average wind speed • at La Guardia Airport", • xlab = "Miles per hour", ylab = "Wind", • col = "orange", border = "brown", • horizontal = TRUE, notch = TRUE) • Box Plots are used for: • To give a comprehensive statistical description of the data through a visual cue. • To identify the outlier points that do not lie in the inter-quartile range of data.
  • 12. Scatter Plot • A scatter plot is composed of many points on a Cartesian plane. Each point denotes the value taken by two parameters and helps us easily identify the relationship between them. • • data(airquality) • • plot(airquality$Ozone, airquality$Month, • main ="Scatterplot Example", • xlab ="Ozone Concentration in parts per billion", • ylab =" Month of observation ", pch = 19) • • Scatter Plots are used in the following scenarios: • To show whether an association exists between bivariate data. • To measure the strength and direction of such a relationship.
  • 13. Heat Map • Heatmap is defined as a graphical representation of data using colors to visualize the value of the matrix. heatmap() function is used to plot heatmap. • Syntax: heatmap(data) • Parameters: data: It represent matrix data, such as values of rows and columns • Return: This function draws a heatmap. • • data <- matrix(rnorm(50, 0, 5), nrow = 5, ncol = 5) • • # Column names • colnames(data) <- paste0("col", 1:5) • rownames(data) <- paste0("row", 1:5) • • # Draw a heatmap • heatmap(data)
  • 14. Scan() • Reading time series of data can be in two types • Scan() and ts() • The scan function reads data into a vector or list from a file or the R console. • data <- data.frame(x1 = c(4, 4, 1, 9), data.frame x2 = c(1, 8, 4, 0), x3 = c(5, 3, 5, 6)) • write.table(data file = "data.txt", row.names = FALSE)
  • 15. TS() • This function can be used to store time series data and creates the time series object. • Ts(data, start,end, frequency) are the parameters.
  • 16. Plotting time series data • Often you may want to plot a time series in R to visualize how the values of the time series are changing over time. • Suppose we have the following dataset in R: