reshape my table into a matrix

Hi, i need to reshape my outcomes into a matrix.So I believe you would be the expert :-).
I am familiar with Holtwinters myself.And my code provides alpha,beta and gamma.
For example the my excel file shows:sales;1,2,3,4,5,6 = 21 total.My code calculates the ABG over 21.and says for example Alpha 0.5 ,Beta 0.97 and Gamma :0.93
so i
I would need to see those values on row bases .

Holtwinters calculation:
salesLogHW <- HoltWinters(salesLog)
HoltWinters(x= salesLog)

Forecast calculation:
HoltWinters(nextYearSales)
autoplot(forecast(fit))
nextYearSales

The challenge is to combine the output of the actual sales with the forementioned calculations on rowbases and create a matrix.

would you be able to help me with that?
i would love to do this together .

cheers.Ron

reprex:

# 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) 
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo
library (ggplot2)

sales <-  read_excel("C:/Users/jenny/Desktop/R Studio/MonthlySales1.xls")
#> New names:
#> * `` -> ...7
#> * `` -> ...8

salesLogHW <- HoltWinters(salesLog)
HoltWinters(x= salesLog)
saleslog(nextYearSales)
autoplot(forecast(fit))
nextYearSales

sales
#> # A tibble: 95 x 8
#>    Month     sales `ETS Forecast` `Hw -alpha` `Hw-beta` `Hw-gamma`  ...7  ...8
#>    <chr>     <dbl>          <dbl>       <dbl>     <dbl>      <dbl> <dbl> <dbl>
#>  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

Created on 2020-05-18 by the reprex package (v0.3.0)

If all you want is reshaping, then what I need to see is examples of the two initial data objects and final combined object. You will need to make at least the combined object manually. In the very simple example below, I have made three objects manually to show the kind of thing I am looking for. I am sure your data are more complex and you may want to use some of the R functions available for posting data. I have included a link at the bottom of the post that may help. If your combined object is large, you do not need to show it entirely. I just need enough to understand how the pieces of the initial objects fit in the final object. If your objects are not data frames or tibbles, you need to tell me what kind of objects they are. You can see this using the class() function.

#the first object
FirstData <- data.frame(A = c("A", "B", "C", "D"), B = c(1,2,3,4))
FirstData
#>   A B
#> 1 A 1
#> 2 B 2
#> 3 C 3
#> 4 D 4

#the second object
SecondData <- data.frame(alpha = c(0.2, 0.1, 0.3, 0.15), beta = c(3,2,1, 6))
SecondData
#>   alpha beta
#> 1  0.20    3
#> 2  0.10    2
#> 3  0.30    1
#> 4  0.15    6

#the combined object
CombindedData <- data.frame(A = c("A", "B", "C", "D"), B = c(1,2,3,4),
                            alpha = c(0.2, 0.1, 0.3, 0.15), beta = c(3,2,1, 6))
CombindedData
#>   A B alpha beta
#> 1 A 1  0.20    3
#> 2 B 2  0.10    2
#> 3 C 3  0.30    1
#> 4 D 4  0.15    6

Created on 2020-05-18 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.