0% found this document useful (0 votes)
4 views2 pages

Practical No - 3

The document outlines a practical exercise for performing data classification using classification algorithms in R or Python, focusing on time series data. It explains the creation of a time series object in R using the ts() function, detailing its syntax and parameters. An example is provided with annual rainfall data from January 2012, demonstrating how to create and plot a time series object.

Uploaded by

priya.rajak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Practical No - 3

The document outlines a practical exercise for performing data classification using classification algorithms in R or Python, focusing on time series data. It explains the creation of a time series object in R using the ts() function, detailing its syntax and parameters. An example is provided with annual rainfall data from January 2012, demonstrating how to create and plot a time series object.

Uploaded by

priya.rajak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical no:3

Aim : Perform the data classification using classification algorithm using R or Python

Time series is a series of data points in which each data point is associated with a timestamp. A
simple example is the price of a stock in the stock market at different points of time on a given
day. Another example is the amount of rainfall in a region at different months of the year. R
language uses many functions to create, manipulate and plot the time series data. The

data for the time series is stored in an R object called time-series object. It is also a R data object
like a vector or data frame.

The time series object is created by using the ts() function.

Syntax

The basic syntax for ts() function in time series analysis is −

timeseries.object.name <- ts(data, start, end, frequency)

Following is the description of the parameters used −

• data is a vector or matrix containing the values used in the time series.

• start specifies the start time for the first observation in time series.

• end specifies the end time for the last observation in time series.

• frequency specifies the number of observations per unit time.

Except the parameter "data" all other parameters are optional

Consider the annual rainfall details at a place starting from January 2012.

We create an R time series object for a period of 12 months and plot it.

> rainfall <-c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071)

> rainfall.timeseries <- ts(rainfall,start = c(2012,1),frequency = 12)

> print(rainfall.timeseries)
> png(file = "rainfall.png")

> plot(rainfall.timeseries)

> dev.off()

null device

​ 1

> plot(rainfall.timeseries)

You might also like