Hi , great .I understand what i i need now.: a matrix
If the reprex is run in Rstudio ,it shows you forecast values , but also Holtwinters Alpha,Beta and Gamma values.(ABG values)
**I am trying to get a combined matrix with my sales values and forecast values with the respective ABG in one simple matrix row wise, .Which matrix function do i need to use you think?
I have my reprex for you :Can you help me showing what code i would need??
load needed packages
library(readr)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(readxl)
library(forecast) # necessary to use forecasting methods
#> Registered S3 method overwritten by 'quantmod':
#> method from
#> as.zoo.data.frame zoo
library(tsintermittent) # TSB (Teunter-Syntetos-Babai) method
#> Loading required package: MAPA
#> Loading required package: parallel
#> Loading required package: RColorBrewer
#> Loading required package: smooth
#> Loading required package: greybox
#> Error: package or namespace load failed for 'greybox' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
#> there is no package called 'RcppParallel'
#> Error: package 'greybox' could not be loaded
library (ggplot2)
sales <- read_excel("C:/Users/jenny/Desktop/R Studio/MonthlySales1.xls")
#> New names:
#> * -> ...7 #> * -> ...8
salesLogHW <- HoltWinters(salesLog)
#> Error in as.ts(x): object 'salesLog' not found
HoltWinters(x= salesLog)
#> Error in as.ts(x): object 'salesLog' not found
findfrequency(nextYearSales)
#> Error in findfrequency(nextYearSales): object 'nextYearSales' not found
sales <- sqrt(salesLogHW$dispersion)
#> Error in eval(expr, envir, enclos): object 'salesLogHW' not found
dnorm(7, mean = coef(nextYearSales), sd = sales)
#> Error in coef(nextYearSales): object 'nextYearSales' not found
autoplot(forecast(fit))
#> Error in forecast(fit): object 'fit' not found
fit <- Arima(sales$sales)
salesLogHW
#> Error in eval(expr, envir, enclos): object 'salesLogHW' not found
nextYearSales
#> Error in eval(expr, envir, enclos): object 'nextYearSales' not found
class =
c("spec_tbl_df", "tbl_df", "tbl", "data.frame")
row.names =
c(NA,-40L)
spec = structure(list(
cols = list(
sales = structure(list(salesLogHW),
class =
c("collector_double", "collector")),
sales = structure(list(sales),
class =
c("collector_double", "collector")),
return = structure(list(HoltWinters(fit)),
class =
c("collector_double", "collector"))
),
default = structure(list(),
class =
c("collector_guess", "collector")),
skip = 10
),
class = "col_spec")
#> Error in structure(list(salesLogHW), class = c("collector_double", "collector")): object 'salesLogHW' not found
sales
#> # A tibble: 95 x 8
#> Month sales ETS Forecast Hw -alpha Hw-beta Hw-gamma ...7 ...8
#>
#> 1 january 43 NA NA NA NA NA NA
#> 2 february 48 NA NA NA NA NA NA
#> 3 march 47 NA NA NA NA NA NA
#> 4 april 48 NA NA NA NA NA NA
#> 5 may 48 NA NA NA NA NA NA
#> 6 june 49 NA NA NA NA NA NA
#> 7 july 38 NA NA NA NA NA NA
#> 8 august 25 NA NA NA NA NA NA
#> 9 september 48 NA NA NA NA NA NA
#> 10 october 48 NA NA NA NA NA NA
#> # ... with 85 more rows
My excel file (MonthlySales1.xls) looks like this:
| Month |
sales |
| january |
43 |
| february |
48 |
| march |
47 |
| april |
48 |
| may |
48 |
| june |
49 |
| july |
38 |
| august |
25 |
| september |
48 |
| october |
48 |
| november |
39 |
| december |
49 |
| january |
41 |
| february |
35 |
| march |
43 |
| april |
47 |
| may |
39 |
| june |
49 |
| july |
37 |
| august |
46 |
| september |
31 |
| october |
45 |
| november |
26 |
| december |
24 |
| january |
48 |
| february |
32 |
| march |
47 |
| april |
49 |
| may |
48 |
| june |
45 |
| july |
43 |
| august |
47 |
| september |
43 |
| october |
27 |
| november |
43 |
| december |
49 |
| january |
48 |
| february |
46 |
| march |
47 |
| april |
34 |
| may |
35 |
| june |
49 |
| july |
42 |
| august |
49 |
| september |
49 |
| october |
43 |
| november |
48 |
| december |
49 |
| january |
47 |
| february |
44 |
| march |
33 |
| april |
46 |
| may |
39 |
| june |
43 |
| july |
49 |
| august |
45 |
| september |
42 |
| october |
46 |
| november |
48 |
| december |
43 |
| january |
48 |
| february |
46 |
| march |
31 |
| april |
49 |
| may |
41 |
| june |
48 |
| july |
43 |
| august |
24 |
| september |
47 |
| october |
49 |
| november |
29 |
| december |
48 |
| january |
49 |
| february |
43 |
| march |
47 |
| april |
39 |
| may |
47 |
| june |
40 |
| july |
46 |
| august |
46 |
| september |
44 |
| october |
41 |
| november |
45 |
| december |
49 |
| january |
46 |
| february |
44 |
| march |
45 |
| april |
43 |
| may |
40 |
| june |
49 |
| july |
49 |
| august |
47 |
| september |
45 |