Let's move on to the data processing part:
- First, we check the datatype of the Sales column in our data:
class(data$Sales)
Note that, in the data, the Sales column is of the factor datatype. We need to make this a numeric datatype in order to use it in our analysis:
data$Sales <- as.numeric(as.character(data$Sales))class(data$Sales)
Now, the class of the Sales column has been changed into a numeric datatype.
- To implement a time series forecast, we need to convert the data into stationary data. We can do this using the diff() function, which will calculate the iterated difference. We pass the value of the argument differences as 1 since we want the differencing to have a lag of 1:
data_differenced = diff(data$Sales, ...