title: "README" author: "Francesco Lazzara" date: "02/06/2020" output: html_document
Mid-term Project: Coding for Data Science academic Year 2019/2020
The package contains a dataset of the Sales of Tesla Motorcars in five European Countries (Norw, Ned, Swi, Ger and UK). The dataset is used for statistical purposes (data analysis, visualization, ecc.) and contains built-in functions for deeper examination of each task.
#Install the package by running the command:
> devtools::install_github("unimi-dse/9768672c")
The packages contains a dataset from "Tesla Europe Registration Stats" (https://teslamotorsclub.com/tmc/threads/tesla-europe-registration-stats.61651/) accuratley modified in order to highlight the most relevant data.
#to look for the information regarding the dataset:
> ?teslasales::dataset
#To see the documentation of each function inside the package:
> ?teslasales::import_data()
?teslasales::barplotly_func()
?teslasales::data_tsplotly()
?teslasales::data_tracesl()
?teslasales::autoparam_tsarima()
?teslasales::manualparam_tsarima()
?teslasales::plot_tsres()
?teslasales::stationary_data()
?teslasales::ts_datastats()
?teslasales::ts_datazoo()
?teslasales::ts_forcdata()
#load the package and run the function to recall the dataset
> require('teslasales')
import_data()
Most of the functions includes arguments which, if not specified, will have as value the default one which is properly indicated inside the documentation, by typing: ?name_of_the_function().
The function import_data() allows to have the dataset in the global environment as a dataframe.
The function barplotly_func() takes as arguments a df, a function to be applied, a character string for the name of the plot and two character strings for the name of both the x and y axis respectively. It gives as output the barplot itself generated using the package plotly.
The function ts_datazoo() creates a time series, using the R-package zoo, from a dataframe. It returns a class zoo element.
The function data_tsplotly() takes as arguments a subsetted df (univariate time series), a character string referring to the initial date of the observations (format: "%Y-%m-%d"), a number referring to the total number of observation to include, a character string referring to the time interval between each observation, a character string for the name of the plot and two other character strings for the name of both the x and y axis respectively. It returns a linechart of the time series generated by the R-package plotly.
The function data_tracesl() takes as arguments two subsetted dataframes, a character string referring to the initial date of the observations (format: "%Y-%m-%d"), a number referring to the total number of observation to include, a character string referring to the time interval between each observation, two character strings for the names of both the time series, another character string for the name of the plot and two other character strings for the name of both the x and y axis respectively. It returns a linechart of the two time series generated by the R-package plotly.
The function ts_datastats() takes as arguments a dataframe and two character vectors, each with two elements referring to the year and a quarter of the initial date and final date respectively. It returns a class 'ts' object.
The function stationary_data() takes as argument a univariate time series and returns a logical object TRUE if the ts is stationary or FALSE if it is not.
The function autoparam_tsarima() takes as arguments a univariate time series object and returns a list containing as a first element the best ARIMA model which fits the data (object class 'Arima') and as second element the stationary ts (object 'ts') computed differentiating it basing on its order of integration.
The function manualparam_tsarima() takes as arguments a univariate time series object and a numeric vector with three elements, which refers to the parameters of the ARIMA models, and returns a list containing as a first element the corrisponding ARIMA model which fits the data (object class 'Arima') and as second element the stationary ts (object 'ts') computed differentiating it basing on its order of integration.
The function plot_tsres() takes as arguments a univariate ARIMA model and a numeric value referred to the degrees of freedom of the distribution of the residuals. It returns three separate plots of the residuals of the corresponding ARIMA model, the ACF and the count, if the argument is an ARIMA object, while a character string with an error if the argument is not an ARIMA one.
The function tsforc_data() takes as arguments a univariate ARIMA model, a numeric value for the periods of the forecast, a vector with two elements for the lower/upper limits of the confidence interval, a character string for the title of the plot and two other character strings for the name of both the x and y axis respectively. It returns the plot of the forecast (line red) for the selected arguments.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.